jayzhan211 commented on code in PR #15588:
URL: https://github.com/apache/datafusion/pull/15588#discussion_r2032396391


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -1997,6 +2010,78 @@ fn is_exactly_true(expr: Expr, info: &impl SimplifyInfo) 
-> Result<Expr> {
     }
 }
 
+// i.e. A * 1 -> A
+// Move this function body out of the large match branch avoid stack overflow
+fn simplify_right_is_one_case<S: SimplifyInfo>(
+    info: &S,
+    left: Box<Expr>,
+    op: &Operator,
+    right: &Expr,
+) -> Result<Transformed<Expr>> {
+    // Check if resulting type would be different due to coercion
+    let left_type = info.get_data_type(&left)?;
+    let right_type = info.get_data_type(right)?;
+    match BinaryTypeCoercer::new(&left_type, op, 
&right_type).get_result_type() {
+        Ok(result_type) => {
+            // Only cast if the types differ
+            if left_type != result_type {

Review Comment:
   since we only care about left side expr, whatever right side is the result 
doesn't change



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to