Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions vortex-array/src/aggregate_fn/fns/min_max/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ pub(super) fn accumulate_bool(
array: &BoolArray,
ctx: &mut ExecutionCtx,
) -> VortexResult<()> {
if array.is_empty() {
return Ok(());
}

let mask = array
.as_ref()
.validity()?
Expand Down
29 changes: 29 additions & 0 deletions vortex-array/src/aggregate_fn/fns/min_max/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,35 @@ mod tests {
Ok(())
}

/// Regression test for <https://github.com/vortex-data/vortex/issues/8145>.
///
/// A chunked array whose first chunk is an *empty* constant array — as produced by
/// `fill_null` on an empty all-null chunk — returned `max = u32::MAX` because
/// `ChunkedArrayAggregate` accumulated the empty chunk, folding its fill scalar into the
/// running min/max. Empty chunks are now skipped during chunked aggregation.
#[test]
fn test_chunked_with_empty_constant_chunk() -> VortexResult<()> {
let mut ctx = LEGACY_SESSION.create_execution_ctx();

let empty = ConstantArray::new(Scalar::primitive(u32::MAX, Nullability::NonNullable), 0)
.into_array();
let chunk1 = PrimitiveArray::new(buffer![7631471u32], Validity::NonNullable).into_array();
let chunk2 = PrimitiveArray::new(buffer![0u32], Validity::NonNullable).into_array();
let chunked = ChunkedArray::try_new(
vec![empty, chunk1, chunk2],
DType::Primitive(PType::U32, Nullability::NonNullable),
)?;

assert_eq!(
min_max(&chunked.into_array(), &mut ctx)?,
Some(MinMaxResult {
min: Scalar::primitive(0u32, Nullability::NonNullable),
max: Scalar::primitive(7631471u32, Nullability::NonNullable),
})
);
Ok(())
}

#[test]
fn test_varbin_all_nulls() -> VortexResult<()> {
let array = VarBinArray::from_iter(
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/arrays/chunked/compute/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ impl DynAggregateKernel for ChunkedArrayAggregate {
};

let mut acc = aggregate_fn.accumulator(chunked.dtype())?;
for chunk in chunked.iter_chunks() {
// Skip empty chunks: they contribute no elements.
for chunk in chunked.non_empty_chunks() {
acc.accumulate(chunk, ctx)?;
}
// Return the partial (not finalized) result, since the outer accumulator
Expand Down
Loading