liukun4515 commented on code in PR #3510:
URL: https://github.com/apache/arrow-datafusion/pull/3510#discussion_r975393489
##########
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:
> maybe in the long term figuring out how to avoid having to remember to
call the const evaluator each struct would be good -- as it too does a expr
tree walk
agree with that
--
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]