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

   A filter applied after `GROUP BY` can change the number of rows counted 
within a group. Reproduced with DataFusion CLI `57.0.0-dev`:
   
   ```sql
   SELECT c
   FROM (
       SELECT a, COUNT(*) AS c
       FROM (VALUES (1), (1)) AS t(a)
       GROUP BY a
   ) AS counts
   WHERE random() < 0.5;
   ```
   
   **Expected:** Both input rows belong to the same group. The query should 
return either `2` or no rows, depending on whether the group passes the filter.
   
   **Actual:** The query can return `1`. `EXPLAIN VERBOSE` shows that 
`push_down_filter` moves `random() < 0.5` below the aggregate, so it runs once 
per input row. If exactly one row passes, the count is `1`.
   
   @DKER2 originally reported this behavior for an aggregate without `GROUP 
BY`. The example above reproduces it with an ordinary grouping key, 
independently of the empty-input behavior tracked in #26545. [Original 
comment](https://github.com/apache/datafusion/issues/26545#issuecomment-6540813770)
   


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