Skip to content

Commit 124c698

Browse files
fix fuzzer issue #7074 (#7077)
maybe? Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 967dce5 commit 124c698

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

vortex-array/src/aggregate_fn/fns/min_max/bool.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ use crate::dtype::Nullability::NonNullable;
1313
use crate::scalar::Scalar;
1414

1515
pub(super) fn accumulate_bool(partial: &mut MinMaxPartial, array: &BoolArray) -> VortexResult<()> {
16+
if array.is_empty() {
17+
return Ok(());
18+
}
19+
1620
let mask = array.validity_mask()?;
1721
let true_non_null = match &mask {
1822
Mask::AllTrue(_) => array.to_bit_buffer(),

vortex-array/src/aggregate_fn/fns/min_max/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,40 @@ mod tests {
610610
Ok(())
611611
}
612612

613+
/// Regression test for <https://github.com/vortex-data/vortex/issues/7074>.
614+
///
615+
/// A chunked all-true bool array with an empty first chunk returned min=false because
616+
/// `accumulate_bool` on the empty chunk incorrectly merged min=false,max=false into the
617+
/// partial state.
618+
#[test]
619+
fn test_bool_chunked_with_empty_chunk() -> VortexResult<()> {
620+
let mut ctx = LEGACY_SESSION.create_execution_ctx();
621+
622+
let empty = BoolArray::new(BitBuffer::from([].as_slice()), Validity::NonNullable);
623+
let chunk1 = BoolArray::new(
624+
BitBuffer::from([true, true].as_slice()),
625+
Validity::NonNullable,
626+
);
627+
let chunk2 = BoolArray::new(
628+
BitBuffer::from([true, true, true].as_slice()),
629+
Validity::NonNullable,
630+
);
631+
let chunked = ChunkedArray::try_new(
632+
vec![empty.into_array(), chunk1.into_array(), chunk2.into_array()],
633+
DType::Bool(Nullability::NonNullable),
634+
)?;
635+
636+
let result = min_max(&chunked.into_array(), &mut ctx)?;
637+
assert_eq!(
638+
result,
639+
Some(MinMaxResult {
640+
min: Scalar::bool(true, Nullability::NonNullable),
641+
max: Scalar::bool(true, Nullability::NonNullable),
642+
})
643+
);
644+
Ok(())
645+
}
646+
613647
#[test]
614648
fn test_varbin_all_nulls() -> VortexResult<()> {
615649
let array = VarBinArray::from_iter(

0 commit comments

Comments
 (0)