Skip to content

Commit

Permalink
Clarify null semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Feb 11, 2024
1 parent 94a60e3 commit 74261e8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions datafusion/core/src/physical_optimizer/pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,17 @@ pub trait PruningStatistics {
/// predicate for each row in the input tables and:
///
/// * Rows that evaluate to `true` are returned in the query results
///
/// * Rows that evaluate to `false` are not returned (“filtered out” or “pruned” or “skipped”).
/// * Rows that evaluate to `NULL` are **NOT** returned (also “filtered out”) – *this property appears many times in the discussion below*
///
/// * Rows that evaluate to `NULL` are **NOT** returned (also “filtered out”).
/// Note: *this treatment of `NULL` is **DIFFERENT** than how `NULL` is treated
/// in the rewritten predicate described below.*
///
/// # `PruningPredicate` Implementation
///
/// Armed with the information in the Background section, we can now understand
/// how the `PruningPredicate` logic works today
/// how the `PruningPredicate` logic works.
///
/// ## Interface
///
Expand Down Expand Up @@ -292,7 +296,9 @@ pub trait PruningStatistics {
///
/// * `NULL`: there MAY be rows that pass the predicate, **KEEPS** the container
/// Note that rewritten predicate can evaluate to NULL when some of
/// the min/max values are not known.
/// the min/max values are not known. *Note that this is different than
/// the SQL filter semantics where `NULL` means the row is filtered
/// out.*
///
/// * `false`: there are no rows that could possibly match the predicate,
/// **PRUNES** the container
Expand All @@ -302,8 +308,8 @@ pub trait PruningStatistics {
/// provided by the `PruningStatistics`. Here are some examples of the rewritten
/// predicates:
///
/// | Original Predicate | Rewritten Predicate |
/// | ------------------ | -------------------- |
/// | Original Predicate | Rewritten Predicate |
/// | ------------------ | --------------------|
/// | `x = 5` | `x_min <= 5 AND 5 <= x_max` |
/// | `x < 5` | `x_max < 5` |
/// | `x = 5 AND y = 10` | `x_min <= 5 AND 5 <= x_max AND y_min <= 10 AND 10 <= y_max` |
Expand Down

0 comments on commit 74261e8

Please sign in to comment.