-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Stop copying LogicalPlan and Exprs in DecorrelatePredicateSubquery
#10318
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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 think it is easier to see what is actually changed in this PR using whitespace blind diff: https://github.com/apache/datafusion/pull/10318/files?w=1
.iter() | ||
.any(|expr| matches!(expr, Expr::InSubquery(_) | Expr::Exists(_))); | ||
if !has_subqueries { | ||
return Ok(Transformed::no(LogicalPlan::Filter(filter))); |
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.
in the common case where there are no subqueries there will be no rewriting / cloning (which is the same as main
|
||
// iterate through all exists clauses in predicate, turning each into a join | ||
let mut cur_input = filter.input.as_ref().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.
this is one avoided clone of the input plan
query, | ||
where_in_expr: Some(expr), | ||
negated: false, | ||
} => in_subquery(expr, query.subquery.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.
these are clones of Arc
s so while this PR removes them and it is less cloning realistically it doesn't matter
@@ -37,7 +37,7 @@ use std::sync::Arc; | |||
use arrow::datatypes::{DataType, Schema}; | |||
use arrow::record_batch::RecordBatch; | |||
|
|||
use datafusion_common::Result; | |||
use datafusion_common::{internal_err, Result}; |
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 the change from #10317 to get the CI to pass
DecorrelatePredicateSubquery
DecorrelatePredicateSubquery
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.
LGTM, thanks! Except for avoiding clones, using if let
to reduce one nest block is also great 👍
Thanks for the review @waynexia |
Which issue does this PR close?
Part of #9637
Closes #10289
Rationale for this change
Reduce copying in
What changes are included in this PR?
DecorrelatePredicateSubquery
Are these changes tested?
covered by existing tests
Are there any user-facing changes?
No