Skip to content

Commit

Permalink
Fix nullability calculation for CASE expressions (apache#2814)
Browse files Browse the repository at this point in the history
* Fix nullability calculation for CASE statements

* Remove println
  • Loading branch information
alamb authored and ovr committed Aug 15, 2022
1 parent 11c7d76 commit 0e05ba1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion datafusion/core/src/logical_plan/expr_schema.rs
Expand Up @@ -172,7 +172,9 @@ impl ExprSchemable for Expr {
} else if let Some(e) = else_expr {
e.nullable(input_schema)
} else {
Ok(false)
// CASE produces NULL if there is no `else` expr
// (aka when none of the `when_then_exprs` match)
Ok(true)
}
}
Expr::Cast { expr, .. } => expr.nullable(input_schema),
Expand Down
4 changes: 3 additions & 1 deletion datafusion/physical-expr/src/expressions/case.rs
Expand Up @@ -406,7 +406,9 @@ impl PhysicalExpr for CaseExpr {
} else if let Some(e) = &self.else_expr {
e.nullable(input_schema)
} else {
Ok(false)
// CASE produces NULL if there is no `else` expr
// (aka when none of the `when_then_exprs` match)
Ok(true)
}
}

Expand Down

0 comments on commit 0e05ba1

Please sign in to comment.