Skip to content

Adds INList and Between expr to skip outer join#21303

Merged
adriangb merged 3 commits intoapache:mainfrom
SubhamSinghal:eliminate-outer-join-inlist-between
Apr 3, 2026
Merged

Adds INList and Between expr to skip outer join#21303
adriangb merged 3 commits intoapache:mainfrom
SubhamSinghal:eliminate-outer-join-inlist-between

Conversation

@SubhamSinghal
Copy link
Copy Markdown
Contributor

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::InList and Expr::Between handling 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

@github-actions github-actions bot added the optimizer Optimizer rules label Apr 1, 2026
Comment on lines +640 to +641
#[test]
fn no_eliminate_left_with_in_list_or_is_null() -> Result<()> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add some SLT tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added slt tests

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Apr 2, 2026
@adriangb adriangb added this pull request to the merge queue Apr 3, 2026
Merged via the queue into apache:main with commit 1e93a67 Apr 3, 2026
35 checks passed
@SubhamSinghal SubhamSinghal deleted the eliminate-outer-join-inlist-between branch April 3, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EliminateOuterJoin does not recognize InList and Between as null-rejecting expressions

2 participants