@@ -8,7 +8,7 @@ use vortex_array::compute::fill_null;
88use vortex_array:: validity:: Validity ;
99use vortex_array:: vtable:: ValidityHelper ;
1010use vortex_array:: { ArrayRef , Canonical , IntoArray , ToCanonical } ;
11- use vortex_buffer:: Buffer ;
11+ use vortex_buffer:: { Buffer , BufferMut } ;
1212use vortex_dtype:: { DType , Nullability , match_each_decimal_value_type, match_each_native_ptype} ;
1313use vortex_error:: { VortexExpect , VortexResult , VortexUnwrap } ;
1414use vortex_scalar:: Scalar ;
@@ -136,7 +136,7 @@ fn fill_decimal_array(
136136 let validity_bits = validity_bool_array. bit_buffer( ) ;
137137 let data_buffer = array. buffer:: <D >( ) ;
138138
139- let mut new_data = Vec :: with_capacity( array. len( ) ) ;
139+ let mut new_data = BufferMut :: with_capacity( array. len( ) ) ;
140140 for i in 0 ..array. len( ) {
141141 if validity_bits. value( i) {
142142 new_data. push( data_buffer[ i] ) ;
@@ -145,7 +145,8 @@ fn fill_decimal_array(
145145 }
146146 }
147147
148- DecimalArray :: from_option_iter( new_data. into_iter( ) . map( Some ) , decimal_dtype)
148+ DecimalArray :: try_new( new_data. freeze( ) , decimal_dtype, result_nullability. into( ) )
149+ . vortex_unwrap( )
149150 . into_array( )
150151 }
151152 }
@@ -340,14 +341,8 @@ mod tests {
340341
341342 let result = fill_null_canonical_array ( array. to_canonical ( ) , & fill_value) . unwrap ( ) ;
342343
343- let expected = DecimalArray :: from_option_iter (
344- [
345- Some ( 100i32 ) ,
346- Some ( 999i32 ) ,
347- Some ( 300i32 ) ,
348- Some ( 999i32 ) ,
349- Some ( 500i32 ) ,
350- ] ,
344+ let expected = DecimalArray :: from_iter (
345+ [ 100i32 , 999i32 , 300i32 , 999i32 , 500i32 ] ,
351346 DecimalDType :: new ( 10 , 2 ) ,
352347 ) ;
353348 assert_arrays_eq ! ( expected, result) ;
@@ -367,10 +362,8 @@ mod tests {
367362
368363 let result = fill_null_canonical_array ( array. to_canonical ( ) , & fill_value) . unwrap ( ) ;
369364
370- let expected = DecimalArray :: from_option_iter (
371- [ Some ( 1000i64 ) , Some ( 9999i64 ) , Some ( 3000i64 ) ] ,
372- DecimalDType :: new ( 15 , 3 ) ,
373- ) ;
365+ let expected =
366+ DecimalArray :: from_iter ( [ 1000i64 , 9999i64 , 3000i64 ] , DecimalDType :: new ( 15 , 3 ) ) ;
374367 assert_arrays_eq ! ( expected, result) ;
375368 }
376369
@@ -388,13 +381,8 @@ mod tests {
388381
389382 let result = fill_null_canonical_array ( array. to_canonical ( ) , & fill_value) . unwrap ( ) ;
390383
391- let expected = DecimalArray :: from_option_iter (
392- [
393- Some ( 10000i128 ) ,
394- Some ( 99999i128 ) ,
395- Some ( 30000i128 ) ,
396- Some ( 99999i128 ) ,
397- ] ,
384+ let expected = DecimalArray :: from_iter (
385+ [ 10000i128 , 99999i128 , 30000i128 , 99999i128 ] ,
398386 DecimalDType :: new ( 20 , 4 ) ,
399387 ) ;
400388 assert_arrays_eq ! ( expected, result) ;
0 commit comments