Skip to content

Commit cd4f271

Browse files
committed
fix[pco]: fill_null cast sliced validity
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 2492c9b commit cd4f271

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

encodings/pco/src/compute/cast.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
use vortex_array::compute::{CastKernel, CastKernelAdapter};
5+
use vortex_array::vtable::ValiditySliceHelper;
56
use vortex_array::{ArrayRef, IntoArray, register_kernel};
67
use vortex_dtype::DType;
78
use vortex_error::VortexResult;
@@ -16,10 +17,21 @@ impl CastKernel for PcoVTable {
1617
// PCO supports: F16, F32, F64, I16, I32, I64, U16, U32, U64
1718
if array.dtype().eq_ignore_nullability(dtype) {
1819
// Create a new validity with the target nullability
19-
let new_validity = array
20-
.unsliced_validity
21-
.clone()
22-
.cast_nullability(dtype.nullability(), array.len())?;
20+
let new_validity = if !dtype.is_nullable() {
21+
// If we are casting to non-nullable we only need to check the sliced validity
22+
// for validity, since the unsliced validity might contain unused nulls.
23+
// We don't do this if the target is nullable since it requires expand the validity
24+
// array.
25+
array
26+
.sliced_validity()
27+
.clone()
28+
.cast_nullability(dtype.nullability(), array.len())?
29+
} else {
30+
array
31+
.unsliced_validity
32+
.clone()
33+
.cast_nullability(dtype.nullability(), array.len())?
34+
};
2335

2436
return Ok(Some(
2537
PcoArray::new(

fuzz/src/array/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub enum Action {
8787
ScalarAt(Vec<usize>),
8888
}
8989

90-
#[derive(Debug)]
90+
#[derive(Debug, Clone)]
9191
pub enum ExpectedValue {
9292
Array(ArrayRef),
9393
Search(SearchResult),

0 commit comments

Comments
 (0)