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



##########
File path: cpp/src/arrow/ipc/metadata_internal.cc
##########
@@ -756,10 +737,35 @@ Status FieldFromFlatbuffer(const flatbuf::Field* field, 
DictionaryMemo* dictiona
     RETURN_NOT_OK(IntFromFlatbuffer(int_data, &index_type));
     ARROW_ASSIGN_OR_RAISE(type,
                           DictionaryType::Make(index_type, type, 
encoding->isOrdered()));
-    *out = ::arrow::field(field_name, type, field->nullable(), metadata);
-    RETURN_NOT_OK(dictionary_memo->AddField(encoding->id(), *out));
-  } else {
-    *out = ::arrow::field(field_name, type, field->nullable(), metadata);
+    dictionary_id = encoding->id();
+  }
+
+  // 4. Is it an extension type?
+  if (metadata != nullptr) {
+    // Look for extension metadata in custom_metadata field
+    int name_index = metadata->FindKey(kExtensionTypeKeyName);
+    if (name_index != -1) {
+      std::string type_name = metadata->value(name_index);
+      int data_index = metadata->FindKey(kExtensionMetadataKeyName);
+      std::string type_data = data_index == -1 ? "" : 
metadata->value(data_index);
+
+      std::shared_ptr<ExtensionType> ext_type = GetExtensionType(type_name);
+      if (ext_type != nullptr) {
+        ARROW_ASSIGN_OR_RAISE(type, ext_type->Deserialize(type, type_data));
+        // Remove the metadata, for faithful roundtripping
+        RETURN_NOT_OK(metadata->DeleteMany({name_index, data_index}));

Review comment:
       @wesm Do you opine to this?




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


Reply via email to