shivbhatia10 commented on code in PR #21057:
URL: https://github.com/apache/datafusion/pull/21057#discussion_r2961166329


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -832,6 +832,16 @@ impl OptimizerRule for PushDownFilter {
                 insert_below(LogicalPlan::Distinct(distinct), new_filter)
             }
             LogicalPlan::Sort(sort) => {
+                // If the sort has a fetch (limit), pushing a filter below
+                // it would change semantics: the limit should apply before
+                // the filter, not after.
+                if sort.fetch.is_some() {

Review Comment:
   For logical nodes as far as I can see only Sort, Limit, and TableScan have 
fetch



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