feat: support dynamic filter pushdown through SortMergeJoinExec#20455
Open
mdashti wants to merge 4 commits intoapache:mainfrom
Open
feat: support dynamic filter pushdown through SortMergeJoinExec#20455mdashti wants to merge 4 commits intoapache:mainfrom
mdashti wants to merge 4 commits intoapache:mainfrom
Conversation
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?
SortMergeJoinExec#20443.Rationale for this change
SortMergeJoinExecuses the defaultgather_filters_for_pushdownimplementation, which marks all parent filters as unsupported. This means dynamic filters from TopK (SortExecwithfetch) cannot pass through sort-merge joins to reach scan nodes — even though the filter routing logic is straightforward for Inner joins.HashJoinExecalready supports this.What changes are included in this PR?
Implements
gather_filters_for_pushdownandhandle_child_pushdown_resultonSortMergeJoinExecfor Inner joins only. For Inner joins the output schema is[left_cols..., right_cols...], so each parent filter is routed to the correct child based on its column references usingChildFilterDescription::from_child_with_allowed_indices(same approach asHashJoinExec). All non-Inner join types conservatively returnall_unsupported.This is a minimal, non-intrusive patch: static filter passthrough only. No dynamic filter creation from join keys (that's a separate, larger feature).
Are these changes tested?
Yes, at three levels:
filter_pushdown.rs) — verify plan structure: left/right filters route to correct children, cross-side filters stay, non-Inner joins reject pushdown, and TopK dynamic filters propagate through SMJ to scan nodes.dynamic_filter_pushdown_config.slt) — end-to-end EXPLAIN verification thatDynamicFilterappears on the correctDataSourceExecfor Inner joins (on both join-key and non-key columns), and is absent for Left joins. Includes correctness checks.smj_filter_pushdown.rs) — 11 tests using in-memory parquet that run each query with and without dynamic filter pushdown and assert identical results. Covers TopK on left/right/join-key columns, DESC order, multi-column sorts, WHERE clauses, LIMIT edge cases, LEFT JOIN correctness, and nested joins.Are there any user-facing changes?
No API changes. Queries using
SortMergeJoinExecwith Inner joins may now benefit from dynamic filter pushdown (e.g. TopK pruning), improving performance forORDER BY ... LIMITqueries over sort-merge joins.