Skip to content

fix: clear handled OFFSET before child recursion in LimitPushdown#22525

Open
kumarUjjawal wants to merge 1 commit into
apache:mainfrom
kumarUjjawal:fix/clear-handled-offset
Open

fix: clear handled OFFSET before child recursion in LimitPushdown#22525
kumarUjjawal wants to merge 1 commit into
apache:mainfrom
kumarUjjawal:fix/clear-handled-offset

Conversation

@kumarUjjawal
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

LimitPushdown carries GlobalRequirements while walking the physical plan.
In the bad plan shape from #22489, an outer OFFSET was already handled above
a sort barrier, but its skip still remained in the state when recursion
continued into the child subtree. That stale skip then merged with an inner
LIMIT and reduced its fetch incorrectly, which caused a grouped row to be
dropped.

The fix is to clear skip once the limit requirement has already been handled,
while keeping fetch so valid limit pushdown into child sorts still happens.

What changes are included in this PR?

Are these changes tested?

Yes

Are there any user-facing changes?

No API Change

@github-actions github-actions Bot added optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataFusion drops grouped row after inner ORDER BY/LIMIT and outer ORDER BY/OFFSET

1 participant