Rich-T-kid commented on code in PR #10831:
URL: https://github.com/apache/arrow-rs/pull/10831#discussion_r3854110781
##########
parquet/src/arrow/array_reader/byte_array_dictionary.rs:
##########
@@ -119,11 +123,47 @@ pub fn make_byte_array_dictionary_reader(
}
}
+/// Convert a dictionary-typed array with string or binary typed values
+/// to one with string or binary view typed values.
+fn convert_values_to_view(array: ArrayRef, to_type: &ArrowType) ->
Result<ArrayRef> {
+ let ArrowType::Dictionary(_, to_value_type) = to_type else {
+ return Err(general_err!(
+ "Cannot convert {} dictionary values to non-dictionary type {}",
+ array.data_type(),
+ to_type
+ ));
+ };
+
+ let data = array.to_data();
+ let values = make_array(data.child_data()[0].clone());
+
+ let new_values: ArrayRef = match to_value_type.as_ref() {
+ ArrowType::Utf8View =>
Arc::new(StringViewArray::from(values.as_string::<i32>())),
+ ArrowType::BinaryView =>
Arc::new(BinaryViewArray::from(values.as_binary::<i32>())),
+ other => {
+ return Err(general_err!(
+ "Cannot convert dictionary values to {}",
+ other
+ ));
+ }
+ };
+
+ let new_data = data
+ .into_builder()
+ .data_type(to_type.clone())
+ .child_data(vec![new_values.to_data()])
+ .build()?;
+
+ Ok(make_array(new_data))
Review Comment:
I think we can avoid the extra validation that `ArrayDataBuilder` performs
here.
##########
parquet/src/arrow/array_reader/byte_array_dictionary.rs:
##########
@@ -119,11 +123,47 @@ pub fn make_byte_array_dictionary_reader(
}
}
+/// Convert a dictionary-typed array with string or binary typed values
+/// to one with string or binary view typed values.
+fn convert_values_to_view(array: ArrayRef, to_type: &ArrowType) ->
Result<ArrayRef> {
Review Comment:
yea after this is shipped I think this is worth making a follow up issue for
to track.
--
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]