haohuaijin commented on issue #7876:
URL: 
https://github.com/apache/arrow-datafusion/issues/7876#issuecomment-1773811464

   >  Perhaps we can't push such predicate through Group or Join at all 🤔
   
   When I use a subquery in place of the HAVING clause to meet the requirements 
in the ticket, like below
   ```sql
   select t.c1, t.r from (select c1, random() as r from aggregate_test_100 
group by c1) as t where t.r > 0.8
   ```
   But I get the wrong result, because the `push_down_filter` push `random()` 
down, and when I disable the `push_down_filter` optimizer rule, I get the 
correct result.
   
   ---------------------------------------------------------------------------
   So should we  consider prohibiting  `volatile` function alias using in 
HAVING clause, like
   ```sql
   select name, random() as r from test group by name having r > 0.2
   ```
   and never push down non deterministic (`volatile`) predicates on `Aggregate` 
to make the below sql correct
   ```sql
   select t.c1, t.r from (select c1, random() as r from aggregate_test_100 
group by c1) as t where t.r > 0.8
   ```
   
   @alamb how do you think, If you don't mind, I will try to fix it.


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

Reply via email to