AdamGS commented on code in PR #9610:
URL: https://github.com/apache/arrow-rs/pull/9610#discussion_r3050966399


##########
parquet-variant-compute/src/unshred_variant.rs:
##########
@@ -73,7 +76,9 @@ pub fn unshred_variant(array: &VariantArray) -> 
Result<VariantArray> {
         if array.is_null(i) {
             value_builder.append_null();
         } else {
-            let metadata = VariantMetadata::new(metadata.value(i));
+            let metadata_bytes = binary_array_value(metadata.as_ref(), i)
+                .expect("metadata field must be a binary-like array");

Review Comment:
   fixed



##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -41,6 +41,36 @@ use parquet_variant::{
 use std::borrow::Cow;
 use std::sync::Arc;
 
+/// Returns the raw bytes at the given index from a binary-like array, return 
`None` if the array isn't binary-like.
+pub(crate) fn binary_array_value(array: &dyn Array, index: usize) -> 
Option<&[u8]> {
+    match array.data_type() {
+        DataType::Binary => Some(array.as_binary::<i32>().value(index)),
+        DataType::LargeBinary => Some(array.as_binary::<i64>().value(index)),
+        DataType::BinaryView => Some(array.as_binary_view().value(index)),
+        _ => None,
+    }
+}
+
+/// Returns `true` if the data type is `Binary`, `LargeBinary`, or 
`BinaryView`.
+fn is_binary_like(dt: &DataType) -> bool {
+    matches!(
+        dt,
+        DataType::Binary | DataType::LargeBinary | DataType::BinaryView
+    )
+}
+
+/// Validates that an array has a binary-like data type.
+fn validate_binary_array(array: &dyn Array, field_name: &str) -> Result<()> {
+    if is_binary_like(array.data_type()) {

Review Comment:
   fixed



-- 
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]

Reply via email to