You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "pitrou (via GitHub)" <gi...@apache.org> on 2024/01/31 15:48:19 UTC

[PR] GH-39865: [C++] Strip extension metadata when importing a registered extension [arrow]

pitrou opened a new pull request, #39866:
URL: https://github.com/apache/arrow/pull/39866

   ### Rationale for this change
   
   When importing an extension type from the C Data Interface and the extension type is registered, we would still leave the extension-related metadata on the storage type.
   
   ### What changes are included in this PR?
   
   Strip extension-related metadata on the storage type if we succeed in recreating the extension type.
   This matches the behavior of the IPC layer and allows for more exact roundtripping.
   
   ### Are these changes tested?
   
   Yes.
   
   ### Are there any user-facing changes?
   
   No, unless people mistakingly rely on the presence of said metadata.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-39865: [C++] Strip extension metadata when importing a registered extension [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #39866:
URL: https://github.com/apache/arrow/pull/39866#issuecomment-1927356788

   CI failures are unrelated, will merge.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-39865: [C++] Strip extension metadata when importing a registered extension [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #39866:
URL: https://github.com/apache/arrow/pull/39866#issuecomment-1928033350

   After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 56951fee35c920ac898c2515896ff3bd752dde97.
   
   There were 2 benchmark results indicating a performance regression:
   
   - Commit Run on `ec2-m5-4xlarge-us-east-2` at [2024-02-05 19:34:29Z](https://conbench.ursa.dev/compare/runs/b049af4be70548d9955d19497564b09e...9e80ac54c61848cbb956019562515090/)
     - [`tpch` (R) with engine=arrow, format=parquet, language=R, memory_map=False, query_id=TPCH-03, scale_factor=10](https://conbench.ursa.dev/compare/benchmarks/065c111541ad736980002cd83fcab79b...065c12f9f796723f80006f61a8a78405)
     - [`tpch` (R) with engine=arrow, format=parquet, language=R, memory_map=False, query_id=TPCH-01, scale_factor=10](https://conbench.ursa.dev/compare/benchmarks/065c10f645a77d878000c0c4b9bb0a06...065c12dd95f879f28000decc40f344dc)
   
   The [full Conbench report](https://github.com/apache/arrow/runs/21244177570) has more details. It also includes information about 5 possible false positives for unstable benchmarks that are known to sometimes produce them.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-39865: [C++] Strip extension metadata when importing a registered extension [arrow]

Posted by "bkietz (via GitHub)" <gi...@apache.org>.
bkietz commented on code in PR #39866:
URL: https://github.com/apache/arrow/pull/39866#discussion_r1476308890


##########
cpp/src/arrow/c/bridge_test.cc:
##########
@@ -3693,13 +3693,23 @@ TEST_F(TestSchemaRoundtrip, Dictionary) {
   }
 }
 
+std::shared_ptr<Field> GetStorageWithMetadata(const std::string& field_name,
+                                              const std::shared_ptr<DataType>& type) {
+  const auto& ext_type = checked_cast<const ExtensionType&>(*type);
+  auto storage_type = ext_type.storage_type();
+  auto md = KeyValueMetadata::Make({kExtensionTypeKeyName, kExtensionMetadataKeyName},
+                                   {ext_type.extension_name(), ext_type.Serialize()});
+  return field(field_name, storage_type, /*nullable=*/true, md);
+}
+
 TEST_F(TestSchemaRoundtrip, UnregisteredExtension) {
   TestWithTypeFactory(uuid, []() { return fixed_size_binary(16); });
   TestWithTypeFactory(dict_extension_type, []() { return dictionary(int8(), utf8()); });
 
   // Inside nested type
-  TestWithTypeFactory([]() { return list(dict_extension_type()); },
-                      []() { return list(dictionary(int8(), utf8())); });
+  TestWithTypeFactory(
+      []() { return list(dict_extension_type()); },
+      []() { return list(GetStorageWithMetadata("item", dict_extension_type())); });

Review Comment:
   Would you mind adding a comment explaining why the nested metadata is present ?



##########
cpp/src/arrow/util/key_value_metadata.cc:
##########
@@ -188,7 +186,7 @@ std::vector<std::pair<std::string, std::string>> KeyValueMetadata::sorted_pairs(
   return pairs;
 }
 
-int KeyValueMetadata::FindKey(const std::string& key) const {
+int KeyValueMetadata::FindKey(std::string_view key) const {

Review Comment:
   :+1: 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-39865: [C++] Strip extension metadata when importing a registered extension [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou merged PR #39866:
URL: https://github.com/apache/arrow/pull/39866


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org