-
Notifications
You must be signed in to change notification settings - Fork 2k
Rewrite physical expressions in execution plans #20009
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,21 @@ pub trait FileSource: Send + Sync { | |
| None | ||
| } | ||
|
|
||
| /// Returns new file source with given filter and projection. | ||
| /// | ||
| /// This method is primarily used during physical plan rewriting (in | ||
| /// `ExecutionPlan::with_physical_expressions`) to update the expressions within a file source. | ||
| /// | ||
| /// It should NOT be used to pass in projections or filters. That pushdown is handled by | ||
| /// optimizer rules. | ||
| fn with_filter_and_projection( | ||
|
Comment on lines
106
to
113
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do add this I think it's worth making it very clear how this is intended to be used. For example, users should not call this from their custom
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the documentation of the method. |
||
| &self, | ||
| _filter: Option<Arc<dyn PhysicalExpr>>, | ||
| _projection: ProjectionExprs, | ||
| ) -> Result<Option<Arc<dyn FileSource>>> { | ||
| Ok(None) | ||
| } | ||
|
|
||
| /// Return execution plan metrics | ||
| fn metrics(&self) -> &ExecutionPlanMetricsSet; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not mentioned at all in the PR description. Can you please explain why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review! I have updated the PR description. This method allows to override the physical expressions within a file source. For example, we will be able to replace placeholder physical expressions. You can see it here (I removed
ResolvePlaceholdersExecfrom the PR, but it worked by finding the placeholders and then replacing them with literals).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the call chain? Is it an optimizer rule that calls this?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataSourceExec::with_physical_expressions->FileScanConfig::with_physical_expressions->FileSource::with_filter_and_projection.This is just one of the implementations of
ExecutionPlan::with_physical_expressions, we just need additional methods that rewrite expressions in internal entities.