diff --git a/arrow-arith/src/aggregate.rs b/arrow-arith/src/aggregate.rs index ae4a5b008a83..f526268bf49e 100644 --- a/arrow-arith/src/aggregate.rs +++ b/arrow-arith/src/aggregate.rs @@ -674,10 +674,7 @@ pub fn bool_and(array: &BooleanArray) -> Option { /// /// Returns `None` if the array is empty or only contains null values. pub fn bool_or(array: &BooleanArray) -> Option { - if array.null_count() == array.len() { - return None; - } - Some(array.true_count() != 0) + max_boolean(array) } /// Returns the sum of values in the primitive array. diff --git a/arrow/benches/aggregate_kernels.rs b/arrow/benches/aggregate_kernels.rs index 71cd24278424..9bb866f364a4 100644 --- a/arrow/benches/aggregate_kernels.rs +++ b/arrow/benches/aggregate_kernels.rs @@ -82,35 +82,53 @@ fn add_benchmark(c: &mut Criterion) { .bench_function("max nonnull mixed", |b| { b.iter(|| max_boolean(&nonnull_bools_mixed)) }) + .bench_function("or nonnull mixed", |b| { + b.iter(|| bool_or(&nonnull_bools_mixed)) + }) .bench_function("min nonnull false", |b| { b.iter(|| min_boolean(&nonnull_bools_all_false)) }) .bench_function("max nonnull false", |b| { b.iter(|| max_boolean(&nonnull_bools_all_false)) }) + .bench_function("or nonnull false", |b| { + b.iter(|| bool_or(&nonnull_bools_all_false)) + }) .bench_function("min nonnull true", |b| { b.iter(|| min_boolean(&nonnull_bools_all_true)) }) .bench_function("max nonnull true", |b| { b.iter(|| max_boolean(&nonnull_bools_all_true)) }) + .bench_function("or nonnull true", |b| { + b.iter(|| bool_or(&nonnull_bools_all_true)) + }) .bench_function("min nullable mixed", |b| { b.iter(|| min_boolean(&nullable_bool_mixed)) }) .bench_function("max nullable mixed", |b| { b.iter(|| max_boolean(&nullable_bool_mixed)) }) + .bench_function("or nullable mixed", |b| { + b.iter(|| bool_or(&nullable_bool_mixed)) + }) .bench_function("min nullable false", |b| { b.iter(|| min_boolean(&nullable_bool_all_false)) }) .bench_function("max nullable false", |b| { b.iter(|| max_boolean(&nullable_bool_all_false)) }) + .bench_function("or nullable false", |b| { + b.iter(|| bool_or(&nullable_bool_all_false)) + }) .bench_function("min nullable true", |b| { b.iter(|| min_boolean(&nullable_bool_all_true)) }) .bench_function("max nullable true", |b| { b.iter(|| max_boolean(&nullable_bool_all_true)) + }) + .bench_function("or nullable true", |b| { + b.iter(|| bool_or(&nullable_bool_all_true)) }); } }