alamb commented on code in PR #8983:
URL: https://github.com/apache/arrow-datafusion/pull/8983#discussion_r1466340498
##########
datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs:
##########
@@ -85,44 +85,35 @@ impl SimplifyExpressions {
};
let info = SimplifyContext::new(execution_props).with_schema(schema);
- let simplifier = ExprSimplifier::new(info);
-
let new_inputs = plan
.inputs()
.iter()
.map(|input| Self::optimize_internal(input, execution_props))
.collect::<Result<Vec<_>>>()?;
- let expr = match plan {
- // Canonicalize step won't reorder expressions in a Join on clause.
- // The left and right expressions in a Join on clause are not
commutative,
- // since the order of the columns must match the order of the
children.
- LogicalPlan::Join(_) => {
- plan.expressions()
- .into_iter()
- .map(|e| {
- // TODO: unify with `rewrite_preserving_name`
- let original_name = e.name_for_alias()?;
- let new_e = simplifier.simplify(e)?;
- new_e.alias_if_changed(original_name)
- })
- .collect::<Result<Vec<_>>>()?
- }
- _ => {
- plan.expressions()
- .into_iter()
- .map(|e| {
- // TODO: unify with `rewrite_preserving_name`
- let original_name = e.name_for_alias()?;
- let cano_e = simplifier.canonicalize(e)?;
- let new_e = simplifier.simplify(cano_e)?;
- new_e.alias_if_changed(original_name)
- })
- .collect::<Result<Vec<_>>>()?
- }
+ let simplifier = ExprSimplifier::new(info);
+
+ // The left and right expressions in a Join on clause are not
commutative,
+ // since the order of the columns must match the order of the children.
+ // Thus, not reorder expressions in a Join `on` clause while
simplifying
Review Comment:
I agree it is not entirely clear what is wrong with canonicalizing the
expressions for joins. I'll add a note to the comment explaining that we don't
really understand the issue (maybe someone can look into it as a follow on)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]