Skip to content

fix(optimizer): Take full expression nullability into account for join key nullability - #25029

Draft
AdamGS wants to merge 5 commits into
apache:mainfrom
AdamGS:adamg/expr-null-fix
Draft

fix(optimizer): Take full expression nullability into account for join key nullability#25029
AdamGS wants to merge 5 commits into
apache:mainfrom
AdamGS:adamg/expr-null-fix

Conversation

@AdamGS

@AdamGS AdamGS commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

NOT IN can return incorrect results when expressions such as NULLIF produce NULL from non-nullable inputs. Anti joins can retain rows that should be excluded, while mark joins lose SQL UNKNOWN.

Nullable correlation expressions can also unnecessarily enable null-aware
execution when both membership values are non-nullable.

What changes are included in this PR?

Determine null-awareness from the full outer membership expression and projected inner value, using their respective input schemas. Correlation predicates do not contribute to membership nullability.

What is the testing strategy for this PR?

Added unit tests and SLT regressions tests that now pass

Are there any user-facing changes?

Some queries are now correct

Signed-off-by: Adam Gutglick <adamgsal@gmail.com>
Signed-off-by: Adam Gutglick <adamgsal@gmail.com>
@github-actions github-actions Bot added optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) labels Sep 7, 2026
@AdamGS AdamGS changed the title Adamg/expr null fix fix(optimizer): Take full expression nullability into account for join key nullability Sep 7, 2026
Signed-off-by: Adam Gutglick <adamgsal@gmail.com>
Signed-off-by: Adam Gutglick <adamgsal@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.11382% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.71%. Comparing base (6ab4ce6) to head (8e33157).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...on/optimizer/src/decorrelate_predicate_subquery.rs 82.11% 7 Missing and 15 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25029      +/-   ##
==========================================
- Coverage   81.72%   81.71%   -0.01%     
==========================================
  Files        1127     1127              
  Lines      416237   416254      +17     
  Branches   416237   416254      +17     
==========================================
+ Hits       340156   340157       +1     
- Misses      56092    56104      +12     
- Partials    19989    19993       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AdamGS
AdamGS marked this pull request as draft September 7, 2026 23:38
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.

Nullable expression over non-null columns are planned as non-null-aware-joins

2 participants