Skip to content

Commit

Permalink
return early if drop_null optimization is not possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 21, 2021
1 parent 86515ca commit 50adcbd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions polars/polars-lazy/src/logical_plan/optimizer/drop_nulls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl OptimizationRule for ReplaceDropNulls {
let mut binary_and_count = 0;
let mut not_null_count = 0;
let mut column_count = 0;
let mut other_count = 0;
for (_, e) in iter {
if is_binary_and(e) {
binary_and_count += 1;
Expand All @@ -54,13 +53,16 @@ impl OptimizationRule for ReplaceDropNulls {
} else if is_lit_true(e) {
// do nothing
} else {
other_count += 1;
// only expected
// - binary and
// - column
// - is not null
// - lit true
// so we can return early
return None;
}
}
if not_null_count == column_count
&& binary_and_count < column_count
&& other_count == 0
{
if not_null_count == column_count && binary_and_count < column_count {
let subset = aexpr_to_root_names(*predicate, expr_arena)
.iter()
.map(|s| s.to_string())
Expand Down

0 comments on commit 50adcbd

Please sign in to comment.