Skip to content

Commit

Permalink
Correctly define validity of sparse arrays with non null fill (#1217)
Browse files Browse the repository at this point in the history
Added test to make sure it stays unbroken
  • Loading branch information
robert3005 authored Nov 5, 2024
1 parent dd67f07 commit 8d03081
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions vortex-array/src/array/sparse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -236,7 +236,6 @@ mod test {
Scalar::null(DType::Primitive(PType::I32, Nullable))
}

#[allow(dead_code)]
fn non_nullable_fill() -> Scalar {
Scalar::from(42i32)
}
Expand Down Expand Up @@ -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<_>>(),
vec![true; 10]
);
}

#[test]
#[should_panic]
fn test_invalid_length() {
Expand Down

0 comments on commit 8d03081

Please sign in to comment.