codephage2020 commented on code in PR #9598:
URL: https://github.com/apache/arrow-rs/pull/9598#discussion_r2985563286


##########
parquet-variant-compute/src/variant_get.rs:
##########
@@ -216,22 +223,63 @@ fn shredded_get_path(
     // Structs are special. Recurse into each field separately, hoping to 
follow the shredding even
     // further, and build up the final struct from those individually shredded 
results.
     if let DataType::Struct(fields) = as_field.data_type() {
-        let children = fields
+        let mut updated_fields = Vec::with_capacity(fields.len());
+        let children: Result<Vec<_>> = fields
             .iter()
             .map(|field| {
-                shredded_get_path(
+                // If the field has VariantType extension metadata, extract it 
as a
+                // VariantArray instead of casting to the declared data type. 
This allows
+                // callers to request structs where some fields remain as 
variants.
+                // See test_struct_extraction_with_variant_fields for usage 
example.
+                let is_variant_field = 
field.try_extension_type::<VariantType>().is_ok();
+                let field_as_type: Option<&Field> = if is_variant_field {
+                    None
+                } else {
+                    Some(field.as_ref())
+                };

Review Comment:
   good catch



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