You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong results: pushing a volatile filter below GROUP BY changes the count #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:
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
Activity
Phoenix500526 commentedon Nov 4, 2026
take
fix: keep volatile filters above aggregates
fix: keep volatile filters above aggregates
fix: keep volatile filters above aggregates (apache#27076)