findepi opened a new issue, #14343:
URL: https://github.com/apache/datafusion/issues/14343

   ### Describe the bug
   
   Invalid query result when searched CASE has nullable condition and boolean 
result
   
   ### To Reproduce
   
   ```sql
   SELECT c, CASE WHEN c > 0 THEN true END
   FROM (VALUES (1), (0), (-1), (NULL)) AS t(c)
   ORDER BY c;
   ```
   
   This returns in DF
   ```
   +------+-------------------------------------------------+
   | c    | CASE WHEN t.c > Int64(0) THEN Boolean(true) END |
   +------+-------------------------------------------------+
   | -1   | false                                           |
   | 0    | false                                           |
   | 1    | true                                            |
   | NULL | NULL                                            |
   +------+-------------------------------------------------+
   ```
   
   ### Expected behavior
   
   This query should never returns a `false` value.
   
   PostgreSQL
   
   ```
   postgres=# SELECT c, CASE WHEN c > 0 THEN true END
   FROM (VALUES (1), (0), (-1), (NULL)) AS t(c)
   ORDER BY c;
    c  | case
   ----+------
    -1 |
     0 |
     1 | t
       |
   ```
   
   Trino
   ```
   trino> SELECT c, CASE WHEN c > 0 THEN true END
       -> FROM (VALUES (1), (0), (-1), (NULL)) AS t(c)
       -> ORDER BY c;
     c   | _col1
   ------+-------
      -1 | NULL
       0 | NULL
       1 | true
    NULL | NULL
   ```
   
   ### Additional context
   
   _No response_


-- 
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...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to