yyy1000 commented on code in PR #8983:
URL: https://github.com/apache/arrow-datafusion/pull/8983#discussion_r1465098531


##########
datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs:
##########
@@ -98,6 +96,7 @@ impl SimplifyExpressions {
             // 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(_) => {
+                let simplifier = 
ExprSimplifier::new(info).with_canonicalize(false);

Review Comment:
   What about moving the initialization of simplifier out like below? It looks 
cleaner. :)
   ```rust
           let simplifier = 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(_) => 
ExprSimplifier::new(info).with_canonicalize(false),
               _ => ExprSimplifier::new(info),
           };
           let expr = 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<_>>>()?;
   ```



-- 
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]

Reply via email to