NGA-TRAN opened a new issue #1244: URL: https://github.com/apache/arrow-datafusion/issues/1244
**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](https://github.com/apache/arrow-datafusion/blob/8f1d533f16e50c309163d2ef7121e2201c80176c/datafusion/src/optimizer/constant_folding.rs#L968), you will see it was rewritten to `col < 10` which is wrong. ``` // col < 10 and boolean(NULL) cannot be rewrite because // it can be either NULL or false depending on the value of `col < 10` let expr = col("col").lt(lit(10)).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 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org