You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
This expression col < 10 and boolean(NULL) can either be NULL or false depending on the result of col < 10. Hence it should not be rewritten to a constant but it is current can.
To Reproduce
Add the following test in optimize_expr_bool_and, you will see it was rewritten to c1 BETWEEN Int32(0) AND Int32(10) which is wrong.
// c1 BETWEEN Int32(0) AND Int32(10) AND Boolean(NULL)
// it can be either NULL or false depending on the value of `c1 BETWEEN Int32(0) AND Int32(10`
let expr = Expr::Between{ expr: Box::new(col("c1")), negated: false, low: Box::new(lit(0)), high: Box::new(lit(10))};
let expr = expr.and(Expr::Literal(ScalarValue::Boolean(None)));
let result = expr.clone().rewrite(&mut rewriter)?;
println!("expr: {:#?} \n result: {:#?}", expr, result);
assert_eq!(expr, result);
Expected behavior
Do not rewritten expression that does not have deterministic result yet
The text was updated successfully, but these errors were encountered:
NGA-TRAN
changed the title
Should not fold a non-constant expression
Should not fold a non-constant expression when it is not clear to do so
Nov 4, 2021
👍 FWIW I think handling NULLs correctly is the single hardest thing in databases (at least the thing that is the most fraught with strange corner cases). The fact we are dealing with them in DataFusion now I think is a sign of its maturity
Describe the bug
This expression
col < 10 and boolean(NULL)
can either be NULL or false depending on the result ofcol < 10
. Hence it should not be rewritten to a constant but it is current can.To Reproduce
Add the following test in optimize_expr_bool_and, you will see it was rewritten to
c1 BETWEEN Int32(0) AND Int32(10)
which is wrong.Expected behavior
Do not rewritten expression that does not have deterministic result yet
The text was updated successfully, but these errors were encountered: