Phoenix500526 opened a new pull request, #27076:
URL: https://github.com/apache/datafusion/pull/27076

   ## Which issue does this PR close?
   
   Closes #27074.
   
   ## Rationale for this change
   
   With two rows in the same group, applying `WHERE random() < 0.5` to the 
result of `COUNT(*)` should return either `2` or no rows. Pushing the filter 
below the aggregate evaluates it for each input row, so the count can 
incorrectly be `1`.
   
   ## What changes are included in this PR?
   
   `PushDownFilter` keeps volatile predicates above an aggregate. It can still 
push a separate predicate on a grouping key below the aggregate, even when the 
two predicates appear in the same `WHERE` clause.
   
   ## What is the testing strategy for this PR?
   
   The regression test in `push_down_filter_regression.slt` checks the logical 
plan for `column1 = 1 AND random() < 0.5`. It verifies that the grouping-key 
filter moves below the aggregate and the random filter stays above it. This 
reproduces the bug without relying on a particular random draw.
   
   ## Are there any user-facing changes?
   
   Yes. A volatile filter on grouped results now decides which groups to return 
while preserving each group's count.


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