alamb commented on code in PR #3510:
URL: https://github.com/apache/arrow-datafusion/pull/3510#discussion_r976804744


##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -98,6 +101,81 @@ impl ExprRewriter for TypeCoercionRewriter<'_> {
 
     fn mutate(&mut self, expr: Expr) -> Result<Expr> {
         match expr {
+            Expr::IsTrue(expr) => {
+                let expr = is_true(get_casted_expr_for_bool_op(&expr, 
&self.schema)?);
+                expr.rewrite(&mut self.const_evaluator)
+            }
+            Expr::IsNotTrue(expr) => {
+                let expr = is_not_true(get_casted_expr_for_bool_op(&expr, 
&self.schema)?);
+                expr.rewrite(&mut self.const_evaluator)
+            }
+            Expr::IsFalse(expr) => {
+                let expr = is_false(get_casted_expr_for_bool_op(&expr, 
&self.schema)?);
+                expr.rewrite(&mut self.const_evaluator)
+            }
+            Expr::IsNotFalse(expr) => {
+                let expr =
+                    is_not_false(get_casted_expr_for_bool_op(&expr, 
&self.schema)?);
+                expr.rewrite(&mut self.const_evaluator)
+            }
+            Expr::Like {
+                negated,
+                expr,
+                pattern,
+                escape_char,
+            } => {
+                let left_type = expr.get_type(&self.schema)?;
+                let right_type = pattern.get_type(&self.schema)?;
+                let coerced_type =
+                    coerce_types(&left_type, &Operator::Like, &right_type)?;
+                let expr = Box::new(expr.cast_to(&coerced_type, 
&self.schema)?);
+                let pattern = Box::new(pattern.cast_to(&coerced_type, 
&self.schema)?);
+                let expr = Expr::Like {
+                    negated,
+                    expr,
+                    pattern,
+                    escape_char,
+                };
+                expr.rewrite(&mut self.const_evaluator)

Review Comment:
   I agree the current framework for expr rewriting / analysis is reaching the 
limits of its existing design. Refactoring the code so it is easier to work 
with sounds like a good idea to me. 
   
   I am open to suggestions -- I think the challenge in any such refactors is 
not only coming up with a good new design but also figuring out how to 
incrementally get the existing code into that new structure



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