-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Optimize EliminateFilter to avoid unnecessary copies #10288 #10302
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
Optimize EliminateFilter to avoid unnecessary copies #10288 #10302
Conversation
| fn rewrite( | ||
| &self, | ||
| plan: LogicalPlan, | ||
| _config: &dyn OptimizerConfig, |
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.
I believe the code in this function uses this so it likely should not start with an underscore as that is a convention to indicate it's not used.
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.
@Omega359 clippy was failed with
Parameter config is only used in recursion. Consider prefixing it with an underscore: _config.
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.
Ahh. My apologies, I didn't see that
027dbc3 to
9e0664f
Compare
| Some(false) | None => Ok(Transformed::yes(LogicalPlan::EmptyRelation( | ||
| EmptyRelation { | ||
| produce_one_row: false, | ||
| schema: unwrap_arc(input).schema().clone(), |
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.
| schema: unwrap_arc(input).schema().clone(), | |
| schema: input.schema().clone(), |
Could we remove the unwrap_arc here?
9e0664f to
4f893ee
Compare
alamb
left a comment
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 -- thank you @dmitrybugakov and @Omega359 -- this looks like a very nice improvement to me ❤️
| .. | ||
| }) => match v { | ||
| Some(true) => Ok(Transformed::yes( | ||
| self.rewrite(unwrap_arc(input), _config)?.data, |
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.
I almost wonder if this recursion is even necessary given that it already does ApplyOrder::TopDown the optimizer itself will call Self::rewrite on the inputs
In other words, it might be possible to do
| self.rewrite(unwrap_arc(input), _config)?.data, | |
| unwrap_arc(input) |
4f893ee to
507f1c5
Compare
alamb
left a comment
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.
Thanks @dmitrybugakov !
| input, | ||
| .. | ||
| }) => match v { | ||
| Some(true) => Ok(Transformed::yes(unwrap_arc(input))), |
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!
| } | ||
|
|
||
| #[test] | ||
| fn eliminate_nested_filters() { |
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.
100% for the new test
Which issue does this PR close?
Closes #10288.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?