Acfboy commented on code in PR #20306:
URL: https://github.com/apache/datafusion/pull/20306#discussion_r2802517231
##########
datafusion/optimizer/src/analyzer/type_coercion.rs:
##########
@@ -744,18 +744,47 @@ impl TreeNodeRewriter for TypeCoercionRewriter<'_> {
});
Ok(Transformed::yes(new_expr))
}
+ // IS NULL / IS NOT NULL / SIMILAR TO / CAST / TRY_CAST validate
+ // their inner expressions during type coercion (previously they
were in
+ // the catch-all branch and skipped validation, which caused
panics at
+ // runtime for invalid inner expressions like zero-argument
function calls).
+ // Detail: <https://github.com/apache/datafusion/issues/20201>
+ //
+ // TODO: reject the invalid cases at planning.
+ Expr::IsNotNull(ref inner_expr) | Expr::IsNull(ref inner_expr) => {
+ let _check_type = inner_expr.get_type(self.schema)?;
+ Ok(Transformed::no(expr))
+ }
+ Expr::SimilarTo(Like {
Review Comment:
I suspect this is because the current implementation has focused more on
optimizing LIKE. Many of these optimizations could likely be applied to SIMILAR
TO as well, but they are probably just yet to be implemented.
For this issue, let's maintain consistency with the existing implementation.
Maybe we should create separate issues to refine how SIMILAR TO is handled.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]