diff --git a/src/vtab/arrow.rs b/src/vtab/arrow.rs index 3d6c23c2..eaefaa79 100644 --- a/src/vtab/arrow.rs +++ b/src/vtab/arrow.rs @@ -257,6 +257,13 @@ pub fn record_batch_to_duckdb_data_chunk( fn primitive_array_to_flat_vector(array: &PrimitiveArray, out_vector: &mut FlatVector) { // assert!(array.len() <= out_vector.capacity()); out_vector.copy::(array.values()); + if let Some(nulls) = array.nulls() { + for (i, null) in nulls.into_iter().enumerate() { + if !null { + out_vector.set_null(i); + } + } + } } fn primitive_array_to_flat_vector_cast( @@ -267,6 +274,13 @@ fn primitive_array_to_flat_vector_cast( let array = arrow::compute::kernels::cast::cast(array, &data_type).unwrap(); let out_vector: &mut FlatVector = out_vector.as_mut_any().downcast_mut().unwrap(); out_vector.copy::(array.as_primitive::().values()); + if let Some(nulls) = array.nulls() { + for (i, null) in nulls.iter().enumerate() { + if !null { + out_vector.set_null(i); + } + } + } } fn primitive_array_to_vector(array: &dyn Array, out: &mut dyn Vector) -> Result<(), Box> {