-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 copying LogicalPlan and Exprs in EliminateNestedUnion #10319
Conversation
In addition to updating the interface for this optimizer, I tried to remove as many copies as possible but I'm still new to rust + datafusion so I'm very much open to suggestions and feedback! |
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 @emgeee
I think this is a step forward for sure
One thing I noticed is that
fn extract_plans_from_union(plan: &Arc<LogicalPlan>) -> Vec<Arc<LogicalPlan>> {
match plan.as_ref() {
LogicalPlan::Union(Union { inputs, schema }) => inputs
.iter()
.map(|plan| Arc::new(coerce_plan_expr_for_schema(plan, schema).unwrap()))
.collect::<Vec<_>>(),
_ => vec![plan.clone()],
}
}
Calls coerce_plan_expr_for_schema
which looks like it may still clone the input and exprs.
Maybe we can try to get rid of those clones too (but as a follow on PR)
Marking as draft as I think this PR is no longer waiting on feedback. Please mark it as ready for review when it is ready for another look |
(also looks like there are some tests that need to be fixed) |
I went ahead and fixed the formatting so all tests pass and managed to remove 1 clone() call from with in the If we want to optimize |
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 you for this contribution @emgeee -- a very nice first contribution .
If we want to optimize coerce_plan_expr_for_schema further, I'd definitely agree a separate PR makes sense as it is called from a number of other locations as well
I agree -- this would be great to remove additional copies. If you had the time PRs would be most appreciated 🙏
@@ -250,7 +250,7 @@ fn coerce_exprs_for_schema( | |||
_ => expr.cast_to(new_type, src_schema), | |||
} | |||
} else { | |||
Ok(expr.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.
🚀
Thanks again @emgeee |
Which issue does this PR close?
Closes #10296.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Existing tests pass
Are there any user-facing changes?