Skip to content

Commit 0fcaeaa

Browse files
committed
Further simplification of is_null
1 parent e44a7cf commit 0fcaeaa

File tree

2 files changed

+235
-230
lines changed

2 files changed

+235
-230
lines changed

datafusion/expr/src/expr_schema.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,10 @@ impl ExprSchemable for Expr {
305305
// For branches with a nullable 'then' expression, try to determine
306306
// if the 'then' expression is ever reachable in the situation where
307307
// it would evaluate to null.
308-
let bounds =
309-
predicate_bounds::evaluate_bounds(w, Some(t), input_schema);
308+
let bounds = match predicate_bounds::evaluate_bounds(w, Some(t), input_schema) {
309+
Err(e) => return Some(Err(e)),
310+
Ok(b) => b,
311+
};
310312

311313
if bounds.is_certainly_not_true() {
312314
// The predicate will never evaluate to true, so the 'then' expression
@@ -320,7 +322,7 @@ impl ExprSchemable for Expr {
320322
})
321323
.next();
322324

323-
let result = if let Some(nullable_then) = nullable_then {
325+
if let Some(nullable_then) = nullable_then {
324326
// There is at least one reachable nullable then
325327
nullable_then.map(|_| true)
326328
} else if let Some(e) = &case.else_expr {
@@ -329,11 +331,7 @@ impl ExprSchemable for Expr {
329331
// CASE produces NULL if there is no `else` expr
330332
// (aka when none of the `when_then_exprs` match)
331333
Ok(true)
332-
};
333-
334-
println!("{} nullable? {result:?}", self);
335-
336-
result
334+
}
337335
}
338336
Expr::Cast(Cast { expr, .. }) => expr.nullable(input_schema),
339337
Expr::ScalarFunction(_func) => {

0 commit comments

Comments
 (0)