Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions vortex-array/src/arrays/decimal/compute/fill_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ impl FillNullKernel for DecimalVTable {
let is_invalid = is_valid.to_bool().bit_buffer().not();
match_each_decimal_value_type!(array.values_type(), |T| {
let mut buffer = array.buffer::<T>().into_mut();
let fill_value = fill_value
.as_decimal()
let decimal_scalar = fill_value.as_decimal();
let decimal_value = decimal_scalar
.decimal_value()
.and_then(|v| v.cast::<T>())
.vortex_expect("top-level fill_null ensure non-null fill value");
.vortex_expect("fill_null requires a non-null fill value");
let fill_value = decimal_value
.cast::<T>()
.vortex_expect("fill value does not fit in array's decimal storage type");
for invalid_index in is_invalid.set_indices() {
buffer[invalid_index] = fill_value;
}
Expand Down
8 changes: 8 additions & 0 deletions vortex-array/src/compute/fill_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ pub fn fill_null(array: &dyn Array, fill_value: &Scalar) -> VortexResult<ArrayRe
}

pub trait FillNullKernel: VTable {
/// Kernel for replacing null values in an array with a fill value.
///
/// TODO(connor): Actually enforce these constraints (so that casts do not fail).
///
/// Implementations can assume that:
/// - The array has at least one null value (not all valid, not all invalid).
/// - The fill value is non-null.
/// - For decimal arrays, the fill value can be successfully cast to the array's storage type.
fn fill_null(&self, array: &Self::Array, fill_value: &Scalar) -> VortexResult<ArrayRef>;
}

Expand Down
Loading