siddubakka commented on code in PR #26164:
URL: https://github.com/apache/datafusion/pull/26164#discussion_r4233180619
##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -435,6 +435,24 @@ impl ExprSchemable for Expr {
Expr::ScalarSubquery(subquery) =>
Ok(scalar_subquery_nullable(subquery)),
Expr::BinaryExpr(BinaryExpr { left, right, op }) => match op {
Operator::IsDistinctFrom | Operator::IsNotDistinctFrom =>
Ok(false),
+ Operator::And => {
+ if contains_is_not_null(left.as_ref(), right.as_ref()) {
Review Comment:
yeah fair point -- so IsNotNull already returns Ok(false) for nullable since
it's always a bool. the thing is when the simplifier turns CASE WHEN x IS NOT
NULL THEN x ELSE false END into x IS NOT NULL AND x, the AND sees that x is
nullable and reports the whole thing as nullable. but semantically it can't be
null -- if x is null then IS NOT NULL(x) is false and alse AND NULL = false.
so the special-casing here is really about AND/OR knowing that an IS NOT NULL
guard makes the other operand safe. happy to explore a different approach if
you have something in mind though!
--
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]