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

   ### Describe the bug
   
   Aggregate and window aggregate `FILTER` clauses fail with an internal error 
when given an untyped `NULL` predicate.
   
   ### To Reproduce
   
   Aggregate:
   
   ```sql
   SELECT count(*) FILTER (WHERE NULL);
   ```
   
   Output:
   
   ```text
   Internal error: Cannot create filter_array from non-boolean predicates.
   ```
   
   Window aggregate:
   
   ```sql
   SELECT count(*) FILTER (WHERE NULL) OVER ()
   FROM (VALUES (1)) AS t(x);
   ```
   
   Output:
   
   ```text
   Internal error: could not cast array of type Null to BooleanArray.
   ```
   
   ### Expected behavior
   
   The equivalent queries with a boolean-typed `NULL` predicate already work:
   
   ```sql
   SELECT count(*) FILTER (WHERE CAST(NULL AS BOOLEAN));
   ```
   
   ```text
   0
   ```
   
   ```sql
   SELECT sum(1) FILTER (WHERE CAST(NULL AS BOOLEAN));
   ```
   
   ```text
   NULL
   ```
   
   Untyped `NULL` predicates in `FILTER` clauses should behave consistently 
rather than producing an internal error.
   
   ### Additional context
   
   ## Environment
   
   * DataFusion 53.1.0
   * Reproduced in `datafusion-cli`


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