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:
Great point. `IsNotNull` already returns `Ok(false)` for nullable since it
always produces a boolean. The issue is specifically with the AND expression
pattern: when the expression simplifier converts `CASE WHEN x IS NOT NULL THEN
x ELSE false END` into `x IS NOT NULL AND x`, the AND expression's default
nullable analysis reports `true` (because `x` is nullable), even though
semantically the expression can never be NULL -- if x is NULL, then `IS NOT
NULL(x)` is false, and `false AND NULL = false`. I'll explore whether there's a
better place to fix this, perhaps in the CASE WHEN nullability analysis or
during CSE rewrites.
--
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]