alan910127 commented on code in PR #15110: URL: https://github.com/apache/datafusion/pull/15110#discussion_r2005666997
########## datafusion/optimizer/src/analyzer/type_coercion.rs: ########## @@ -290,19 +290,72 @@ impl<'a> TypeCoercionRewriter<'a> { right: Expr, right_schema: &DFSchema, ) -> Result<(Expr, Expr)> { + if let Expr::Literal(ref lit_value) = left { + if let Some(casted) = + try_cast_literal_to_type(lit_value, op, &right.get_type(right_schema)?) + { + return Ok((casted, right)); + }; + } + + if let Expr::Literal(ref lit_value) = right { + if let Some(casted) = + try_cast_literal_to_type(lit_value, op, &left.get_type(left_schema)?) Review Comment: @findepi thank you for the review. This file is for avoiding the cast to be applied to the column, and I was trying to emulate the behavior of duckdb and postgres. So I was wondering should we even consider the operator here, as duckdb and postgres both cast the literal anyways, even throwing error if the literal can not be casted. -- 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