Skip to content
Merged
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
32 changes: 10 additions & 22 deletions fuzz/src/array/fill_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use vortex_array::compute::fill_null;
use vortex_array::validity::Validity;
use vortex_array::vtable::ValidityHelper;
use vortex_array::{ArrayRef, Canonical, IntoArray, ToCanonical};
use vortex_buffer::Buffer;
use vortex_buffer::{Buffer, BufferMut};
use vortex_dtype::{DType, Nullability, match_each_decimal_value_type, match_each_native_ptype};
use vortex_error::{VortexExpect, VortexResult, VortexUnwrap};
use vortex_scalar::Scalar;
Expand Down Expand Up @@ -136,7 +136,7 @@ fn fill_decimal_array(
let validity_bits = validity_bool_array.bit_buffer();
let data_buffer = array.buffer::<D>();

let mut new_data = Vec::with_capacity(array.len());
let mut new_data = BufferMut::with_capacity(array.len());
for i in 0..array.len() {
if validity_bits.value(i) {
new_data.push(data_buffer[i]);
Expand All @@ -145,7 +145,8 @@ fn fill_decimal_array(
}
}

DecimalArray::from_option_iter(new_data.into_iter().map(Some), decimal_dtype)
DecimalArray::try_new(new_data.freeze(), decimal_dtype, result_nullability.into())
.vortex_unwrap()
.into_array()
}
}
Expand Down Expand Up @@ -340,14 +341,8 @@ mod tests {

let result = fill_null_canonical_array(array.to_canonical(), &fill_value).unwrap();

let expected = DecimalArray::from_option_iter(
[
Some(100i32),
Some(999i32),
Some(300i32),
Some(999i32),
Some(500i32),
],
let expected = DecimalArray::from_iter(
[100i32, 999i32, 300i32, 999i32, 500i32],
DecimalDType::new(10, 2),
);
assert_arrays_eq!(expected, result);
Expand All @@ -367,10 +362,8 @@ mod tests {

let result = fill_null_canonical_array(array.to_canonical(), &fill_value).unwrap();

let expected = DecimalArray::from_option_iter(
[Some(1000i64), Some(9999i64), Some(3000i64)],
DecimalDType::new(15, 3),
);
let expected =
DecimalArray::from_iter([1000i64, 9999i64, 3000i64], DecimalDType::new(15, 3));
assert_arrays_eq!(expected, result);
}

Expand All @@ -388,13 +381,8 @@ mod tests {

let result = fill_null_canonical_array(array.to_canonical(), &fill_value).unwrap();

let expected = DecimalArray::from_option_iter(
[
Some(10000i128),
Some(99999i128),
Some(30000i128),
Some(99999i128),
],
let expected = DecimalArray::from_iter(
[10000i128, 99999i128, 30000i128, 99999i128],
DecimalDType::new(20, 4),
);
assert_arrays_eq!(expected, result);
Expand Down
Loading