Skip to content

Null rejection trait#21623

Open
SubhamSinghal wants to merge 4 commits intoapache:mainfrom
SubhamSinghal:null-rejection-trait
Open

Null rejection trait#21623
SubhamSinghal wants to merge 4 commits intoapache:mainfrom
SubhamSinghal:null-rejection-trait

Conversation

@SubhamSinghal
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Today, EliminateOuterJoin uses extract_non_nullable_columns() with explicit pattern matching for each Expr variant to determine if a WHERE predicate rejects NULL rows. Every new expression type (LIKE, IS TRUE, etc.) must be added manually to this function. This is brittle and doesn't scale.

This PR introduces is_null and is_not_true trait methods on PhysicalExpr, so each expression type defines its own null-rejection behavior. This also enables future use in parquet pruning at the physical layer.

What changes are included in this PR?

New trait methods on PhysicalExpr:

  • is_null(null_columns) -> Option<bool>: returns whether the expression is guaranteed to evaluate to NULL when the given columns are NULL
  • is_not_true(null_columns) -> Option<bool>: returns whether the expression is guaranteed to evaluate to NULL or FALSE when the given columns are NULL

Are these changes tested?

Yes, with UT

Are there any user-facing changes?

No

@github-actions github-actions bot added physical-expr Changes to the physical-expr crates optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant