fix: Prevent predicate pushdown across Sort with baked-in slice - #26804
Merged
ritchie46 merged 2 commits intoMar 5, 2026
Merged
Conversation
gautamvarmadatla
requested review from
MarcoGorelli,
alexander-beedie,
c-peters,
orlp and
ritchie46
as code owners
March 4, 2026 20:54
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26804 +/- ##
==========================================
+ Coverage 81.30% 81.58% +0.27%
==========================================
Files 1802 1802
Lines 246972 246991 +19
Branches 3086 3086
==========================================
+ Hits 200810 201498 +688
+ Misses 45371 44703 -668
+ Partials 791 790 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Thanks @gautamvarmadatla |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes : #26803
So, TLDR is #26495 swapped the optimizer pass order so that slice pushdown now runs before predicate pushdown, which caused the issue. Previously, the standalone
SliceIR node acted as a hard barrier in predicate pushdown, callingno_pushdown_restart_optto stop all predicates from passing through. With slice pushdown running first, thatSlicenode gets baked intoSort { slice: Some(...) }before predicate pushdown runs. Predicate pushdown treatsSortas push-through (it callspushdown_and_continue), and there was no special-case barrier behavior forSort { slice: Some(...) }. So user predicates now slip past the row limit.Also, the
DynamicPredchange in the same commit compounds the problem for single-column sorts by injecting an additional predicate into the same pushdown flow, but it is not the fundamental reason user predicates cross the row-limit boundary.To fix this i basically drained accumulated predicates to local when
Sorthas a baked-in slice and reapplied them above the node viaoptional_apply_predicate.