Fix EliminateLimit not eliminating limits under LogicalPlan::Extension nodes. - #25577
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25577 +/- ##
==========================================
+ Coverage 82.42% 82.45% +0.03%
==========================================
Files 1139 1140 +1
Lines 435372 436600 +1228
Branches 435372 436600 +1228
==========================================
+ Hits 358845 360002 +1157
- Misses 54826 54836 +10
- Partials 21701 21762 +61 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
masonh22
marked this pull request as ready for review
September 21, 2026 20:58
martin-g
reviewed
Sep 22, 2026
alamb
reviewed
Sep 22, 2026
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.
Which issue does this PR close?
Rationale for this change
#22298 updated the logical plan optimizer to apply optimization rules in place to avoid
Arcunwrap/rewraps with a newmap_children_mut()function. This function unconditionally updates the children of all logical plan nodes except forLogicalPlan::Extensionnodes. ForExtensionnodes, it only updates the children if the mapping function returnstruefor any of the children, signifying that a child was updated.When the
EliminateLimitrule prunes a limit that has 0 skip and fetch, it modifies the node but does not return that it modified anything. This is fine for every case except for if the limit is underneath aLogicalPlan::Extensionnode, since it that case we ignore the output from the rule.What changes are included in this PR?
This change adds a failing test, a fix to
EliminateLimit, and changesmap_children_mut()to unconditionally update the children ofLogicalPlan::Extensionnodes. The change tomap_children_mut()could be left out, but I wouldn't be surprised if there are other optimization rules that modify the node without returningtransformed=true, so this is done to avoid finding and fixing all of those cases.What is the testing strategy for this PR?
I added a test that replicates the issue and fails without my fixes.
Are there any user-facing changes?
No