diff --git a/encodings/runend/src/compress.rs b/encodings/runend/src/compress.rs index c7f6f1bc7..811dd4935 100644 --- a/encodings/runend/src/compress.rs +++ b/encodings/runend/src/compress.rs @@ -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()), @@ -304,6 +304,19 @@ mod test { assert_eq!(values.maybe_null_slice::(), 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::(), vec![5]); + assert_eq!(values.maybe_null_slice::(), vec![0]); + } + #[test] fn decode() { let ends = PrimitiveArray::from(vec![2, 5, 10]);