-
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
fix: don't unifies projection if expr is non-trival #8454
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.
Thank you for the contribution @haohuaijin . This change makes sense to me
cc @mustafasrepo and @Dandandan
let mut column_ref_map: HashMap<Column, usize> = HashMap::new(); | ||
|
||
// Collect the column references usage in the outer projection. | ||
projection.expr().iter().for_each(|(expr, _)| { |
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 may be mistaken and it may not matter, but I think this will prevent pushing down exprs that refer to the same column more than once
Projection exprs=[b as c, b as d]
Projection exprs = [a as b]
Into
Projection exprs=[a as c, a as d]
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.
We don't prevent Column
and Literal
push_down. We prevent other express push_down, used to prevent multiple evaluation of the same expression.
if column_ref_map.iter().any(|(column, count)| {
*count > 1 && !is_expr_trivial(&child.expr()[column.index()].0.clone())
}) {
return Ok(None);
}
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 @haohuaijin for this PR. It is LGTM!.
Co-authored-by: Alex Huang <huangweijun1001@gmail.com>
Thank you @haohuaijin,. @Weijun-H and @mustafasrepo |
* fix: don't unifies projection if expr is non-trival * Update datafusion/core/src/physical_optimizer/projection_pushdown.rs Co-authored-by: Alex Huang <huangweijun1001@gmail.com> --------- Co-authored-by: Alex Huang <huangweijun1001@gmail.com>
Which issue does this PR close?
Closes #8453
Rationale for this change
What changes are included in this PR?
don't unifies projection if the expression in non-trival. see discussion in #8296
Are these changes tested?
Are there any user-facing changes?
add physical plan check in
.slt
test