gruuya commented on PR #12943: URL: https://github.com/apache/datafusion/pull/12943#issuecomment-2443517408
Are we certain that the filter should not be pushed down, and moreover that it can be pushed down in some cases but not in other cases? This is unexpected to me, as my intuition assumes that the `WHERE` clause always filters the pre-aggregated data (i.e. it is always pushed down)—double checking on Postgres this seems to be confirmed ```sql postgres@localhost:postgres> explain select distinct on (a) a, b from foo where b = 1 order by a, b desc; +-----------------------------------------------------------------+ | QUERY PLAN | |-----------------------------------------------------------------| | Unique (cost=38.44..38.50 rows=11 width=8) | | -> Sort (cost=38.44..38.47 rows=11 width=8) | | Sort Key: a | | -> Seq Scan on foo (cost=0.00..38.25 rows=11 width=8) | | Filter: (b = 1) | +-----------------------------------------------------------------+ ``` Granted with `DISTINCT ON` you can't use `HAVING` (as there's no explicit `GROUP BY`), but I guess one should be using a subquery with an additional filter on top of the nested `DISTINCT ON` in such cases. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org