adriangb commented on code in PR #21057:
URL: https://github.com/apache/datafusion/pull/21057#discussion_r2967300045
##########
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:
I think it would be reasonable to add a `fn fetch(&self) -> Option<usize>`
to `LogicalPlan`. We could make the match exhaustive / have no fall-through so
that anyone adding a new variant has to update it. At least then it will be in
one place and also closer to the change -> better for human and machine to pick
it up.
--
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]