alamb commented on code in PR #20702:
URL: https://github.com/apache/datafusion/pull/20702#discussion_r2892311798
##########
datafusion/optimizer/src/simplify_expressions/regex.rs:
##########
@@ -68,12 +68,11 @@ pub fn simplify_regex_expr(
// Handle the special case for ".*" pattern
if pattern == ANY_CHAR_REGEX_PATTERN {
let new_expr = if mode.not {
- // not empty
- let empty_lit = Box::new(string_scalar.to_expr(""));
+ let null_bool = lit(ScalarValue::Boolean(None));
Expr::BinaryExpr(BinaryExpr {
- left,
- op: Operator::Eq,
- right: empty_lit,
+ left: Box::new(left.is_not_null()),
Review Comment:
I think this case should be `is_null` rather than `is_not_null`
I think this because when `left` is null, The expression `null !~ '.*'`
should also evaluate to `null`
However, as written (`col IS NOT NULL AND NULL`) will evaluate
```sql
col IS NOT NULL AND NULL
--> FALSE AND NULL
--> FALSE
```
If the transformation is `col IS NULL AND NULL` 🤯 then:
```sql
col IS NULL AND NULL
--> true AND NULL
--> NULL
```
As expected
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]