You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generalize null-rejection checks into a reusable expression trait #21597
Several optimizer rules need to determine whether an expression "rejects nulls" — i.e., returns NULL/false when one or more input columns are NULL. Today this logic lives in EliminateOuterJoin's extract_non_nullable_columns() with explicit pattern matching for each expression type (comparison, IN, BETWEEN, LIKE, IS TRUE/FALSE, etc.). Every new expression type must be added manually.
Describe the solution you'd like
Introduce a NullRejection trait on expressions, similar to Apache Calcite's Strong class:
traitPhysicalExpr{// ... existing methods .../// Returns whether this expression is guaranteed to be not-true/// (i.e., NULL or false) when all given columns are NULL.////// - `Some(true)`: definitely rejects nulls (safe to eliminate outer join)/// - `Some(false)`: definitely does NOT reject nulls/// - `None`: unknown (conservative default, assume not null-rejecting)fnis_not_true(&self,all_null_cols:&[&Column]) -> Option<bool>{None}}
Each expression type overrides with simple structural logic:
// Comparison (=, >, <, etc.): NULL on either side → NULL resultimplPhysicalExprforBinaryExpr{fnis_not_true(&self,all_null_cols:&[&Column]) -> Option<bool>{match(self.left.is_not_true(all_null_cols),self.right.is_not_true(all_null_cols)){(Some(true), _) | (_,Some(true)) => Some(true),(Some(false),Some(false)) => Some(false),
_ => None,}}}
Activity
SubhamSinghal commentedon Apr 13, 2026
take