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


##########
cpp/src/parquet/arrow/schema.cc:
##########
@@ -1161,28 +1219,42 @@ Result<bool> ApplyOriginalMetadata(const Field& 
origin_field, SchemaField* infer
   if (origin_type->id() == ::arrow::Type::EXTENSION) {
     const auto& origin_extension_type =
         checked_cast<const ::arrow::ExtensionType&>(*origin_type);
+    std::string origin_extension_name = origin_extension_type.extension_name();
+
+    // Whether or not the inferred type is also an extension type. This can 
occur when
+    // arrow_extensions_enabled is true in the ArrowReaderProperties. 
Extension types
+    // are not currently inferred for any other reason.
+    bool arrow_extension_inferred =
+        inferred->field->type()->id() == ::arrow::Type::EXTENSION;
+
+    bool restore_file_extension = false;
+    if (origin_extension_name == kFileExtensionName && 
arrow_extension_inferred) {
+      const auto& inferred_extension_type =
+          checked_cast<const 
::arrow::ExtensionType&>(*inferred->field->type());
+      if (FileStorageTypesCompatible(origin_extension_type.storage_type(),
+                                     inferred_extension_type.storage_type())) {
+        inferred->field =
+            inferred->field->WithType(inferred_extension_type.storage_type());
+        restore_file_extension = true;

Review Comment:
   FYI, there is no test coverage on this line. Removing it doesn't cause any 
test to fail.



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