From 8d030813eadb76d563fad82c7e5c98cbb9309bb3 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Tue, 5 Nov 2024 16:17:28 +0000 Subject: [PATCH] Correctly define validity of sparse arrays with non null fill (#1217) Added test to make sure it stays unbroken --- vortex-array/src/array/sparse/mod.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/vortex-array/src/array/sparse/mod.rs b/vortex-array/src/array/sparse/mod.rs index 33ca689760..70c795d9d9 100644 --- a/vortex-array/src/array/sparse/mod.rs +++ b/vortex-array/src/array/sparse/mod.rs @@ -210,7 +210,7 @@ impl ArrayValidity for SparseArray { .with_dyn(|a| a.logical_validity().into_array()), self.len(), self.indices_offset(), - false.into(), + true.into(), ) } .vortex_expect("Error determining logical validity for sparse array"); @@ -236,7 +236,6 @@ mod test { Scalar::null(DType::Primitive(PType::I32, Nullable)) } - #[allow(dead_code)] fn non_nullable_fill() -> Scalar { Scalar::from(42i32) } @@ -396,6 +395,23 @@ mod test { ); } + #[test] + fn sparse_logical_validity_non_null_fill() { + let array = sparse_array(non_nullable_fill()); + + assert_eq!( + array + .with_dyn(|a| a.logical_validity()) + .into_array() + .into_bool() + .unwrap() + .boolean_buffer() + .iter() + .collect::>(), + vec![true; 10] + ); + } + #[test] #[should_panic] fn test_invalid_length() {