Adds INList and Between expr to skip outer join#21303
Merged
adriangb merged 3 commits intoapache:mainfrom Apr 3, 2026
Merged
Conversation
adriangb
reviewed
Apr 2, 2026
Comment on lines
+640
to
+641
| #[test] | ||
| fn no_eliminate_left_with_in_list_or_is_null() -> Result<()> { |
Contributor
There was a problem hiding this comment.
Would it be possible to add some SLT tests?
Contributor
Author
There was a problem hiding this comment.
added slt tests
adriangb
approved these changes
Apr 3, 2026
adriangb
approved these changes
Apr 3, 2026
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?
EliminateOuterJoin does not recognize InList and Between as null-rejecting expressions
Rationale for this change
The EliminateOuterJoin optimizer rule converts outer joins to inner joins when WHERE clause predicates reject null rows from the nullable side. However, extract_non_nullable_columns only recognizes a limited set of expression types (comparisons, AND/OR, NOT, IS NOT NULL, CAST/TRY_CAST) and falls through to a no-op for all others. This means common null-rejecting expressions like IN and BETWEEN are not recognized, causing outer joins to be preserved unnecessarily.
What changes are included in this PR?
Added
Expr::InListandExpr::Betweenhandling to extract_non_nullable_columns in eliminate_outer_join.rs. Both expressions are null-rejecting on their input column — if the input is NULL, the result is always NULL regardless of the list/range contents.Are these changes tested?
Yes, 8 new unit tests added
Are there any user-facing changes?
No API changes