Skip to content

Commit

Permalink
[pruning] Add shortcut when all units have been pruned (apache#8675)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted-Jiang authored Dec 30, 2023
1 parent 7fc663c commit 7f440e1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions datafusion/core/src/physical_optimizer/pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ impl PruningPredicate {
builder.combine_array(&arrow::compute::not(&results)?)
}
}
// if all containers are pruned (has rows that DEFINITELY DO NOT pass the predicate)
// can return early without evaluating the rest of predicates.
if builder.check_all_pruned() {
return Ok(builder.build());
}
}
}

Expand Down Expand Up @@ -380,6 +385,11 @@ impl BoolVecBuilder {
fn build(self) -> Vec<bool> {
self.inner
}

/// Check all containers has rows that DEFINITELY DO NOT pass the predicate
fn check_all_pruned(&self) -> bool {
self.inner.iter().all(|&x| !x)
}
}

fn is_always_true(expr: &Arc<dyn PhysicalExpr>) -> bool {
Expand Down

0 comments on commit 7f440e1

Please sign in to comment.