Repository navigation
keep fetch when merge FilterExec in FilterPushdown - #21070
Merged
Merged
Conversation
haohuaijin
commented
Mar 20, 2026
Contributor
Author
|
Thanks for you reviews @adriangb |
haohuaijin
added a commit
to haohuaijin/arrow-datafusion
that referenced
this pull request
Mar 21, 2026
## Which issue does this PR close? - Closes apache#21069 ## Rationale for this change - see apache#21069 ## What changes are included in this PR? When `FilterPushdown` merges/eliminates a `FilterExec`, it now correctly propagates the `fetch` limit that was on the FilterExec. Previously, if a `FilterExec` had a fetch (e.g., LIMIT 10) and all its predicates were fully pushed down to a under `FilterExec`, the FilterExec node was dropped — and the fetch was silently lost, potentially returning more rows than requested. The fix: - If the FilterExec being eliminated has a fetch, propagate it to the child node via `with_fetch()` - If both the outer and inner nodes have a fetch, use min(outer, inner) to preserve the tighter constraint ## Are these changes tested? yes, add some test cases, trying to reproduce use sql, current not able ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
de-bgunter
pushed a commit
to de-bgunter/datafusion
that referenced
this pull request
Mar 24, 2026
## Which issue does this PR close? - Closes apache#21069 ## Rationale for this change - see apache#21069 ## What changes are included in this PR? When `FilterPushdown` merges/eliminates a `FilterExec`, it now correctly propagates the `fetch` limit that was on the FilterExec. Previously, if a `FilterExec` had a fetch (e.g., LIMIT 10) and all its predicates were fully pushed down to a under `FilterExec`, the FilterExec node was dropped — and the fetch was silently lost, potentially returning more rows than requested. The fix: - If the FilterExec being eliminated has a fetch, propagate it to the child node via `with_fetch()` - If both the outer and inner nodes have a fetch, use min(outer, inner) to preserve the tighter constraint ## Are these changes tested? yes, add some test cases, trying to reproduce use sql, current not able ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
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
What changes are included in this PR?
When
FilterPushdownmerges/eliminates aFilterExec, it now correctly propagates thefetchlimit that was on the FilterExec.Previously, if a
FilterExechad a fetch (e.g., LIMIT 10) and all its predicates were fully pushed down to a underFilterExec, the FilterExec node was dropped — and the fetch was silently lost, potentially returning more rows than requested.The fix:
with_fetch(), if the clid node do not supportwith_fetchadd a local limit node.Are these changes tested?
yes, add some test cases, trying to reproduce use sql, current not able
Are there any user-facing changes?