adriangb commented on code in PR #15769:
URL: https://github.com/apache/datafusion/pull/15769#discussion_r2074207291


##########
datafusion/physical-optimizer/src/optimizer.rs:
##########
@@ -95,6 +95,10 @@ impl PhysicalOptimizer {
             // as that rule may inject other operations in between the 
different AggregateExecs.
             // Applying the rule early means only directly-connected 
AggregateExecs must be examined.
             Arc::new(LimitedDistinctAggregation::new()),
+            // The FilterPushdown rule tries to push down filters as far as it 
can.
+            // For example, it will push down filtering from a `FilterExec` to
+            // a `DataSourceExec`, or from a `TopK`'s current state to a 
`DataSourceExec`.
+            Arc::new(FilterPushdown::new()),

Review Comment:
   @alamb this is actually an issue, moving this does not work alongside 
https://github.com/apache/datafusion/pull/15770:
   - `SortExec`s filter has to be pushed down after any manipulation of the 
`SortExec`s in the plan (otherwise it will be referencing a `SortExec` that 
gets removed / replaced and not function)
   - `EnforceSorting` creates new `SortExec`s, so `FilterPushdown` would have 
to come after that
   - The extra `RepartitionExec`s get introduced in `EnforceDistribution`
   - Since `EnforceSorting` must come after `EnforceDistribution` there is no 
correct place to put `FilterPushdown`
   



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

Reply via email to