Skip to content

Commit

Permalink
fix: RunEnd array correctly encodes all null arrays (#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Dec 13, 2024
1 parent 528b760 commit e8323ac
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion encodings/runend/src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn runend_encode(array: &PrimitiveArray) -> VortexResult<(PrimitiveArray, Ar
// We can trivially return an all-null REE array
return Ok((
PrimitiveArray::from(vec![array.len() as u64]),
ConstantArray::new(Scalar::null(array.dtype().clone()), array.len()).into_array(),
ConstantArray::new(Scalar::null(array.dtype().clone()), 1).into_array(),
));
}
Validity::Array(a) => Some(a.into_bool()?.boolean_buffer()),
Expand Down Expand Up @@ -304,6 +304,19 @@ mod test {
assert_eq!(values.maybe_null_slice::<i32>(), vec![1, 0, 2, 3, 0]);
}

#[test]
fn encode_all_null() {
let arr = PrimitiveArray::from_vec(
vec![0, 0, 0, 0, 0],
Validity::from(BooleanBuffer::new_unset(5)),
);
let (ends, values) = runend_encode(&arr).unwrap();
let values = values.into_primitive().unwrap();

assert_eq!(ends.maybe_null_slice::<u64>(), vec![5]);
assert_eq!(values.maybe_null_slice::<i32>(), vec![0]);
}

#[test]
fn decode() {
let ends = PrimitiveArray::from(vec![2, 5, 10]);
Expand Down

0 comments on commit e8323ac

Please sign in to comment.