andygrove commented on code in PR #3101:
URL: https://github.com/apache/arrow-datafusion/pull/3101#discussion_r966389952


##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -86,29 +87,45 @@ impl ExprRewriter for TypeCoercionRewriter {
     }
 
     fn mutate(&mut self, expr: Expr) -> Result<Expr> {
-        match expr {
+        match &expr {
             Expr::BinaryExpr { left, op, right } => {
                 let left_type = left.get_type(&self.schema)?;
                 let right_type = right.get_type(&self.schema)?;
-                let coerced_type = coerce_types(&left_type, &op, &right_type)?;
+                let coerced_type = coerce_types(&left_type, op, &right_type)?;
                 Ok(Expr::BinaryExpr {
-                    left: Box::new(left.cast_to(&coerced_type, &self.schema)?),
-                    op,
-                    right: Box::new(right.cast_to(&coerced_type, 
&self.schema)?),
+                    left: Box::new(
+                        left.as_ref().clone().cast_to(&coerced_type, 
&self.schema)?,
+                    ),
+                    op: *op,
+                    right: Box::new(
+                        right
+                            .as_ref()
+                            .clone()
+                            .cast_to(&coerced_type, &self.schema)?,
+                    ),
                 })
             }
+            Expr::Like { pattern, .. }
+            | Expr::ILike { pattern, .. }
+            | Expr::SimilarTo { pattern, .. } => match 
pattern.get_type(&self.schema)? {
+                DataType::Utf8 => Ok(expr.clone()),

Review Comment:
   This is for the regular expression pattern, which is typically a literal 
string but could, in theory, be a column reference. I'm not sure if it would 
make sense to support LargeUtf8 here?



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