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


##########
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:
   Honestly, it would be even nicer if `Fields` were an `IndexMap`, which gives 
O(1) name lookup that many consumers all over arrow would benefit from. But 
that would be a pretty major change and potentially impacts efficiency as well.



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