-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve Filter Handling in Join Optimization: Retain Inferred Predicates as Join Filters #17090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kosiew
wants to merge
9
commits into
apache:main
Choose a base branch
from
kosiew:non-inner-join-filter-pushdown-16973
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+488
−32
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
feat: enhance predicate handling for join optimization - Retain inferred predicates that cannot be pushed through joins as join filters for dynamic filter pushdown. - Update join filter assertions in tests to reflect new logic. - Add tests for dynamic filter pushdown scenarios, including: - Left join with a filter on the preserved side. - Right join with a filter on the preserved side. - Handling filters that do not restrict nulls. ```
…ecution plan clarity
6dddfc6
to
8337f80
Compare
Dandandan
reviewed
Aug 9, 2025
@@ -2730,7 +2787,7 @@ mod tests { | |||
assert_optimized_plan_equal!( | |||
plan, | |||
@r" | |||
Right Join: Using test.a = test2.a | |||
Right Join: Using test.a = test2.a Filter: test.a <= Int64(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These filters seem redundant (always true)?
… add inferred predicate alias handling
9f9f0ac
to
5e4472d
Compare
f8310ec
to
5ae7863
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
core
Core DataFusion crate
logical-expr
Logical plan and expressions
optimizer
Optimizer rules
sqllogictest
SQL Logic Tests (.slt)
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
Previously, inferred predicates that couldn't be pushed down through a join (due to join type restrictions) were discarded. This behavior missed opportunities to apply dynamic filter pushdown later in the optimization pipeline. By retaining such predicates as join filters, we enable further optimization opportunities and improve query performance.
What changes are included in this PR?
Updated
push_down_all_join
logic to retain inferred predicates as join filters when they can't be pushed down to either side.Adjusted plan formatting to reflect join filters.
Added new test cases to cover:
Are these changes tested?
Yes, this PR includes multiple unit tests to verify the correctness of the optimizer behavior for:
Are there any user-facing changes?
Yes:
These changes are internal to query optimization and do not alter public APIs, but users may observe better query performance and more comprehensive filter handling in EXPLAIN plans.