fix: don't infer join predicates for null-aware joins in push_down_filter - #23901
Merged
Conversation
…lter
`push_down_filter` infers equi-key predicates across a join's ON keys and
pushes them to the opposite side. For a null-aware join (the `LeftAnti`
join produced by `NOT IN` with a nullable subquery), an outer predicate on
the left key such as `outer.id > 5` is rewritten to `sub.id > 5` and pushed
onto the right/subquery input. Because the inferred predicate must be
null-rejecting to be pushed, this drops the subquery's NULL rows, which
breaks the three-valued `NOT IN` semantics: a NULL in the subquery key must
reach the join so the result is empty (UNKNOWN for every row).
For example:
CREATE TABLE outer_t(id INT) AS VALUES (3), (7);
CREATE TABLE sub_t(id INT) AS VALUES (NULL);
SELECT id FROM outer_t WHERE id > 5 AND id NOT IN (SELECT id FROM sub_t);
correctly returns no rows, but previously returned `7` because `sub.id > 5`
was inferred onto the subquery, dropping its NULL row.
Skip predicate inference entirely when `join.null_aware` is set. This
mirrors the null-aware guard added to `FilterNullJoinKeys` in apache#23848.
Add a `push_down_filter` regression unit test asserting no predicate is
inferred onto the subquery side of a null-aware `LeftAnti` join, and SLT
coverage for the failing query (including a `prefer_hash_join = false`,
multi-partition variant).
Co-authored-by: Claude Code
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23901 +/- ##
==========================================
- Coverage 80.65% 80.65% -0.01%
==========================================
Files 1092 1092
Lines 371106 371175 +69
Branches 371106 371175 +69
==========================================
+ Hits 299323 299366 +43
- Misses 53937 53944 +7
- Partials 17846 17865 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AdamGS
approved these changes
Jul 25, 2026
Member
Author
|
Thanks @AdamGS for review |
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
push_down_filterinfers equi-key predicates across a join's ON keys and pushes them to the opposite side. For a null-aware join (theLeftAntijoin produced byNOT INwith a nullable subquery), an outer predicate on the left key likeouter.id > 5is rewritten tosub.id > 5and pushed onto the subquery input. Since the inferred predicate must be null-rejecting to be pushed, this drops the subquery's NULL rows and breaks the three-valuedNOT INsemantics — a NULL in the subquery key must reach the join so the result is empty.Same class of bug as #23848, in a different rule.
What changes are included in this PR?
infer_join_predicateswhenjoin.null_awareis set (mirrors the fix: Handle null-aware joins correctly inFilterNullJoinKeyswhen its enabled #23848 guard onFilterNullJoinKeys).push_down_filterunit test asserting no predicate is inferred onto the subquery side of a null-awareLeftAntijoin.prefer_hash_join = false/ multi-partition variant.Are these changes tested?
Yes — new unit test (verified it fails without the guard) and SLT cases. The full optimizer lib suite passes.
Are there any user-facing changes?
No, aside from the correctness fix.