alamb commented on code in PR #20702:
URL: https://github.com/apache/datafusion/pull/20702#discussion_r2892383444


##########
datafusion/sqllogictest/test_files/simplify_expr.slt:
##########
@@ -44,10 +44,10 @@ query TT
 explain select b from t where b !~ '.*'
 ----
 logical_plan
-01)Filter: t.b = Utf8View("")
+01)Filter: t.b IS NOT NULL AND Boolean(NULL)

Review Comment:
   I think we should  add a test that actually executes `col !~ .*` for a 
column that has `'foo'`, `''`, and `null`
   
   Specifically like this (the ::text is needed for postgres):
   
   ```sql
   -- Reproducer for regex simplification of `col !~ '.*'`
   -- Input values: 'foo', '', NULL
   
   WITH t(col) AS (
       VALUES
         ('foo'::text),
         (''::text),
         (NULL::text)
     )
     SELECT
       col,
       col !~ '.*' AS not_match_dot_star
     FROM t;
   
   ```
   
   
   Should result in 
   ```sql
   +------+-----------------+
   | a    | baseline_result |
   +------+-----------------+
   | foo  | false           |
   |      | false           |
   | NULL | NULL            |
   +------+-----------------+
   ```
   
   Here is what current datafusion does
   
   ```sql
   andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion2$ datafusion-cli
   DataFusion CLI v52.1.0
   > WITH t(col) AS (
       VALUES
         ('foo'::text),
         (''::text),
         (NULL::text)
     )
     SELECT
       col,
       col !~ '.*' AS not_match_dot_star
     FROM t;
   +------+--------------------+
   | col  | not_match_dot_star |
   +------+--------------------+
   | foo  | false              |
   |      | true               |
   | NULL | NULL               |
   +------+--------------------+
   3 row(s) fetched.
   Elapsed 0.038 seconds.
   ```
   
   Here is what postgres says
   
   ```sql
   postgres=#   WITH t(col) AS (
       VALUES
         ('foo'::text),
         (''::text),
         (NULL::text)
     )
     SELECT
       col,
       col !~ '.*' AS not_match_dot_star
     FROM t;
    col | not_match_dot_star
   -----+--------------------
    foo | f
        | f
        |
   (3 rows)
   ```
   
   I think this branch will not get the right value for `col IS NULL`



-- 
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]

Reply via email to