tustvold commented on code in PR #4511:
URL: https://github.com/apache/arrow-rs/pull/4511#discussion_r1261497906
##########
arrow-cast/src/cast.rs:
##########
@@ -3645,39 +3641,15 @@ where
}
/// Helper function that takes a primitive array and casts to a (generic) list
array.
-fn cast_primitive_to_list<OffsetSize: OffsetSizeTrait + NumCast>(
+fn cast_values_to_list<O: OffsetSizeTrait>(
array: &dyn Array,
- to: &Field,
- to_type: &DataType,
+ to: &FieldRef,
cast_options: &CastOptions,
) -> Result<ArrayRef, ArrowError> {
- // cast primitive to list's primitive
- let cast_array = cast_with_options(array, to.data_type(), cast_options)?;
- // create offsets, where if array.len() = 2, we have [0,1,2]
- // Safety:
- // Length of range can be trusted.
- // Note: could not yet create a generic range in stable Rust.
- let offsets = unsafe {
- MutableBuffer::from_trusted_len_iter(
- (0..=array.len()).map(|i| OffsetSize::from(i).expect("integer")),
- )
- };
-
- let list_data = unsafe {
- ArrayData::new_unchecked(
- to_type.clone(),
- array.len(),
- Some(cast_array.null_count()),
- cast_array.nulls().map(|b| b.inner().sliced()),
Review Comment:
There is no reason to duplicate the null buffer here, so I opted to just
remove this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]