HuaHuaY commented on code in PR #50892:
URL: https://github.com/apache/arrow/pull/50892#discussion_r3910434635


##########
cpp/src/parquet/arrow/schema.cc:
##########
@@ -1059,9 +1094,16 @@ Result<bool> ApplyOriginalStorageMetadata(const Field& 
origin_field,
 
       // Apply original metadata recursively to children
       for (int i = 0; i < inferred_type->num_fields(); ++i) {
+        std::shared_ptr<::arrow::Field> origin_child;
+        if (match_children_by_name) {
+          origin_child = checked_cast<const ::arrow::StructType&>(*origin_type)
+                             .GetFieldByName(inferred_type->field(i)->name());
+        } else {
+          origin_child = origin_type->field(i);
+        }
         ARROW_ASSIGN_OR_RAISE(
             const bool child_modified,
-            ApplyOriginalMetadata(*origin_type->field(i), 
&inferred->children[i]));
+            ApplyOriginalMetadata(*origin_child, &inferred->children[i]));

Review Comment:
   1. We have checked the child names in `FileStorageTypesCompatible` so 
`origin_child` will not be null.
   2. Under the current execution path, `match_children_by_name` is true only 
for the `FILE` type, so here is always a `StructType`.



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