Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop most copying LogicalPlan and Exprs in ScalarSubqueryToJoin #10489

Merged
merged 1 commit into from
May 17, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented May 13, 2024

Which issue does this PR close?

Closes #10294

Rationale for this change

Make the optimizer faster by not copying

What changes are included in this PR?

  1. Stop copying LogicalPlan and Exprs in ScalarSubqueryToJoin when there are no ScalarSubqueries
  2. Use the OptimizerRule::rewrite API

Are these changes tested?

Existing CI

Are there any user-facing changes?

No (maybe minimal performance improvements)

@github-actions github-actions bot added the optimizer Optimizer rules label May 13, 2024
@alamb alamb force-pushed the alamb/scalar_subquery_to_join branch from e7867cf to d69b128 Compare May 14, 2024 10:52
@alamb alamb changed the title Stop copying LogicalPlan and Exprs in ScalarSubqueryToJoin Stop most copying LogicalPlan and Exprs in ScalarSubqueryToJoin May 14, 2024
match plan {
LogicalPlan::Filter(filter) => {
// Optimization: skip the rest of the rule and its copies if
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note there is a still a bunch of copying in the actual rewrite logic itself below, but I could not figure out a way to remove it easily as there are several paths that return the original (unmodified) plan for unsupported subqueries

I think we would have to split the check for "is rewrite supported" and the "do the rewrite" logic or something

Given this isn't a tall pole in planning, I don't have any more time to spend on this particular rule so I want to call this good enough

} else {
Ok(Transformed::no(expr))
}
// replace column references with entry in map, if it exists
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove some indenting using the api added in #10448, but the logic is the same

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thanks @alamb for improving the analyzer

@alamb
Copy link
Contributor Author

alamb commented May 17, 2024

Thank you for the review @comphead

@alamb alamb merged commit 32b63ff into apache:main May 17, 2024
25 checks passed
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
@alamb alamb deleted the alamb/scalar_subquery_to_join branch October 18, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop copying LogicalPlan and Exprs in ScalarSubqueryToJoin
2 participants