pitrou commented on a change in pull request #8366:
URL: https://github.com/apache/arrow/pull/8366#discussion_r500861539



##########
File path: cpp/src/parquet/arrow/schema.cc
##########
@@ -688,32 +688,21 @@ Status GetOriginSchema(const std::shared_ptr<const 
KeyValueMetadata>& metadata,
 
 Result<bool> ApplyOriginalMetadata(const Field& origin_field, SchemaField* 
inferred);
 
-using NestedFieldRewrapper = std::function<Status(FieldVector, SchemaField*)>;
-
-Status RewrapStructField(FieldVector new_children, SchemaField* inferred) {
-  inferred->field = 
inferred->field->WithType(::arrow::struct_(std::move(new_children)));
-  return Status::OK();
-}
-
-Status RewrapListField(FieldVector new_children, SchemaField* inferred) {
-  DCHECK_EQ(new_children.size(), 1);
-  inferred->field = inferred->field->WithType(::arrow::list(new_children[0]));
-  return Status::OK();
-}
-
-// XXX Perhaps add a DataType::WithFields method?
-NestedFieldRewrapper GetNestedFieldRewrapper(const ArrowType& origin_type,
-                                             const ArrowType& inferred_type) {
+std::function<std::shared_ptr<::arrow::DataType>(FieldVector)> 
GetNestedFactory(
+    const ArrowType& origin_type, const ArrowType& inferred_type) {
   switch (inferred_type.id()) {
     case ::arrow::Type::STRUCT:
       if (origin_type.id() == ::arrow::Type::STRUCT) {
-        return RewrapStructField;
+        return ::arrow::struct_;
       }
       break;
     case ::arrow::Type::LIST:
       // TODO also allow LARGE_LIST and FIXED_SIZE_LIST
       if (origin_type.id() == ::arrow::Type::LIST) {
-        return RewrapListField;
+        return [](FieldVector fields) {
+          DCHECK_EQ(fields.size(), 1);

Review comment:
       Normally no, because we already checked that `origin_type->num_fields() 
== inferred_type->num_fields()`.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to