Skip to content

Commit e2f4f2c

Browse files
authored
Fix: decimal cast error message (#5821)
This should also make sure that the fuzzer doesn't keep reporting the wrong error message. As for the TODO, see #5820 Signed-off-by: Connor Tsui <[email protected]>
1 parent c7b0ef9 commit e2f4f2c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

vortex-array/src/arrays/decimal/compute/fill_null.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ impl FillNullKernel for DecimalVTable {
2828
let is_invalid = is_valid.to_bool().bit_buffer().not();
2929
match_each_decimal_value_type!(array.values_type(), |T| {
3030
let mut buffer = array.buffer::<T>().into_mut();
31-
let fill_value = fill_value
32-
.as_decimal()
31+
let decimal_scalar = fill_value.as_decimal();
32+
let decimal_value = decimal_scalar
3333
.decimal_value()
34-
.and_then(|v| v.cast::<T>())
35-
.vortex_expect("top-level fill_null ensure non-null fill value");
34+
.vortex_expect("fill_null requires a non-null fill value");
35+
let fill_value = decimal_value
36+
.cast::<T>()
37+
.vortex_expect("fill value does not fit in array's decimal storage type");
3638
for invalid_index in is_invalid.set_indices() {
3739
buffer[invalid_index] = fill_value;
3840
}

vortex-array/src/compute/fill_null.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ pub fn fill_null(array: &dyn Array, fill_value: &Scalar) -> VortexResult<ArrayRe
5959
}
6060

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

0 commit comments

Comments
 (0)