Skip to content

Commit

Permalink
Fix nullability calculation for CASE statements
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Jun 29, 2022
1 parent 3cfd15b commit ffc605d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion datafusion/expr/src/expr_schema.rs
Expand Up @@ -170,7 +170,10 @@ impl ExprSchemable for Expr {
} else if let Some(e) = else_expr {
e.nullable(input_schema)
} else {
Ok(false)
println!("AAL IN none else expr");
// 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

0 comments on commit ffc605d

Please sign in to comment.