scovich commented on code in PR #8392:
URL: https://github.com/apache/arrow-rs/pull/8392#discussion_r2368028203
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -894,35 +891,31 @@ fn typed_value_to_variant(typed_value: &ArrayRef, index:
usize) -> Variant<'_, '
///
/// So cast them to get the right type.
fn cast_to_binary_view_arrays(array: &dyn Array) -> Result<ArrayRef,
ArrowError> {
- let new_type = map_type(array.data_type());
+ let new_type = rewrite_to_view_types(array.data_type());
cast(array, &new_type)
}
/// replaces all instances of Binary with BinaryView in a DataType
-fn map_type(data_type: &DataType) -> DataType {
+fn rewrite_to_view_types(data_type: &DataType) -> DataType {
match data_type {
DataType::Binary => DataType::BinaryView,
- DataType::List(field) => {
- let new_field = field
- .as_ref()
- .clone()
- .with_data_type(map_type(field.data_type()));
- DataType::List(Arc::new(new_field))
- }
+ DataType::List(field) => DataType::List(rewrite_field_type(field)),
DataType::Struct(fields) => {
- let new_fields: Fields = fields
- .iter()
- .map(|f| {
- let new_field =
f.as_ref().clone().with_data_type(map_type(f.data_type()));
- Arc::new(new_field)
- })
- .collect();
+ let new_fields: Fields =
fields.iter().map(rewrite_field_type).collect();
DataType::Struct(new_fields)
Review Comment:
The `let` produces a longer line than just using it directly...
```suggestion
DataType::Struct(fields.iter().map(rewrite_field_type).collect())
```
--
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]