Is your feature request related to a problem or challenge?
Discussion thread
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:
trait PhysicalExpr {
// ... 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)
fn is_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 result
impl PhysicalExpr for BinaryExpr {
fn is_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,
}
}
}
Describe alternatives you've considered
No response
Additional context
No response
Is your feature request related to a problem or challenge?
Discussion thread
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'sextract_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
NullRejectiontrait on expressions, similar to Apache Calcite'sStrongclass:Each expression type overrides with simple structural logic:
Describe alternatives you've considered
No response
Additional context
No response