nuno-faria commented on code in PR #25416:
URL: https://github.com/apache/datafusion/pull/25416#discussion_r4041152027


##########
datafusion/sqllogictest/test_files/push_down_filter_regression.slt:
##########
@@ -640,3 +640,37 @@ drop table t1;
 
 statement ok
 drop table t2;
+
+# A filter on a volatile group key must stay above the aggregate. Below the
+# aggregate, the filter evaluates the key again and sees a different value.
+query TT
+EXPLAIN SELECT k, c FROM (SELECT random() < 0.5 AS k, count(*) AS c FROM 
generate_series(1, 10000) GROUP BY random() < 0.5) WHERE k;

Review Comment:
   ```suggestion
   EXPLAIN SELECT k, c FROM (SELECT random() < 0.5 AS k, count(*) AS c FROM 
generate_series(1, 10000) GROUP BY 1) WHERE k;
   ```
   
   For clarity, I think it would be better to explicitly use the column on the 
group instead of repeating the random, since with a different random the 
predicate would not be pushed.



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