You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/10/06 17:06:28 UTC

[GitHub] [arrow] pitrou commented on a change in pull request #8366: ARROW-9943: [C++] Recursively apply Arrow metadata when reading from Parquet

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



##########
File path: cpp/src/parquet/arrow/schema.cc
##########
@@ -689,10 +686,91 @@ Status GetOriginSchema(const std::shared_ptr<const KeyValueMetadata>& metadata,
 // but that is not necessarily present in the field reconstitued from Parquet data
 // (for example, Parquet timestamp types doesn't carry timezone information).
 
-Status ApplyOriginalStorageMetadata(const Field& origin_field, SchemaField* inferred) {
+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();
+}
+
+NestedFieldRewrapper GetNestedFieldRewrapper(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;
+      }
+      break;
+    case ::arrow::Type::LIST:
+      // TODO also allow LARGE_LIST and FIXED_SIZE_LIST

Review comment:
       @emkornfield I think you'll be able to add your changes here.




----------------------------------------------------------------
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:
users@infra.apache.org