-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Don't add filters to projection in TableScan #7670
Don't add filters to projection in TableScan #7670
Conversation
|
||
let expected = "\ | ||
Projection: Int32(1) AS a\ | ||
\n TableScan: test projection=[a], full_filters=[b = Int32(1)]"; |
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.
Here is the important fix - before this would add b
to the projection (even if it was not needed in the plan above). This would lead to unnecessary scanning columns supported by the filter.
@@ -147,10 +147,6 @@ impl OptimizerRule for PushDownProjection { | |||
if !scan.projected_schema.fields().is_empty() => | |||
{ | |||
let mut used_columns: HashSet<Column> = HashSet::new(); | |||
// filter expr may not exist in expr in projection. |
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 added filters to the projection since #5188
FYI @jackwener
Add test WIP fix Fix filter after scan Totally reemove filter to column extraction Fix test Update tests 1 Update tests 2 Update tests 3
b283946
to
27069f0
Compare
FYI @alamb this might help with enabling parquet filter pushdown as well by default |
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.
Nice!
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 looks great @Dandandan -- thank you so much ❤️
@@ -2759,8 +2705,7 @@ Projection: a, b | |||
// For right anti, filter of the left side can be pushed down. | |||
let expected = "RightAnti Join: test1.a = test2.a Filter: test2.b > UInt32(2)\ | |||
\n Projection: test1.a, test1.b\ | |||
\n Filter: test1.b > UInt32(1)\ | |||
\n TableScan: test1\ | |||
\n TableScan: test1, full_filters=[test1.b > UInt32(1)]\ |
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.
it is great to see the filters pushed into the scans as part of this test
Add test WIP fix Fix filter after scan Totally reemove filter to column extraction Fix test Update tests 1 Update tests 2 Update tests 3
Which issue does this PR close?
Closes #7683
Rationale for this change
We don't want to scan columns not needed by the rest of the plan.
What changes are included in this PR?
We change the scan implementations to apply the filters before the projection.
This way we don't need to add the filters to the projection in to make the plan correct.
Are these changes tested?
Existing tests + new test.
Are there any user-facing changes?