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


##########
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 think the SQL level with analyse/expr/optimizer should be refactor.
   We are missing some formal logic like spark SQL framework or other SQL 
framework.
   This makes it very difficult for us to do some features or optimization.



-- 
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...@arrow.apache.org

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

Reply via email to