scovich commented on code in PR #8446:
URL: https://github.com/apache/arrow-rs/pull/8446#discussion_r2379844875


##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -972,10 +1059,82 @@ fn typed_value_to_variant<'a>(
                 "Unsupported typed_value type: {}",
                 typed_value.data_type()
             );
-            Variant::Null
+            builder.append_value(Variant::Null);
         }
-    };
-    value.into()
+    }
+
+    // Only a partially shredded struct is allowed to have values for both 
columns
+    if value.is_some_and(|v| v.is_valid(index)) {
+        return Err(ArrowError::InvalidArgumentError(
+            "Invalid variant, conflicting value and typed_value".to_string(),
+        ));
+    }
+
+    Ok(())
+}
+
+/// Handles reconstruction of variant objects from shredded struct data
+fn struct_typed_value_to_variant(
+    typed_value: &ArrayRef,
+    value: Option<&BinaryViewArray>,
+    index: usize,
+    metadata: &VariantMetadata,
+    builder: &mut impl VariantBuilderExt,
+) -> Result<(), ArrowError> {
+    let struct_array = typed_value.as_struct();
+    let mut obj_builder = builder.try_new_object()?;
+
+    // Track all shredded field names -- we must ignore them when processing 
value fields below.
+    let mut shredded_field_names = std::collections::HashSet::new();

Review Comment:
   It would be nice to build the hash table just once per array, instead of 
rebuilding at every row access, but there's nowhere to materialize it -- 
`VariantArray` doesn't build any kind of tree and instead directly "mounts" the 
underlying arrays. So this just adds to the inefficiency that 
`VariantArray::value` docs warn about.



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