Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nullability calculation for CASE expressions #2814

Merged
merged 2 commits into from Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion datafusion/expr/src/expr_schema.rs
Expand Up @@ -170,7 +170,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 @@ -243,7 +243,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