pitrou commented on code in PR #47242:
URL: https://github.com/apache/arrow/pull/47242#discussion_r2285384982


##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -941,46 +942,57 @@ TEST_F(TestConvertParquetSchema, ParquetVariant) {
       PrimitiveNode::Make("metadata", Repetition::REQUIRED, 
ParquetType::BYTE_ARRAY);
   auto value =
       PrimitiveNode::Make("value", Repetition::REQUIRED, 
ParquetType::BYTE_ARRAY);
-
-  auto variant =
-      GroupNode::Make("variant_unshredded", Repetition::OPTIONAL, {metadata, 
value});
+  auto variant = GroupNode::Make("variant_unshredded", Repetition::OPTIONAL,
+                                 {metadata, value}, LogicalType::Variant());
   parquet_fields.push_back(variant);
 
-  {
-    // Test converting from parquet schema to arrow schema.
-    std::vector<std::shared_ptr<Field>> arrow_fields;
-    auto arrow_metadata =
-        ::arrow::field("metadata", ::arrow::binary(), /*nullable=*/false);
-    auto arrow_value = ::arrow::field("value", ::arrow::binary(), 
/*nullable=*/false);
-    auto arrow_variant = ::arrow::struct_({arrow_metadata, arrow_value});
-    arrow_fields.push_back(
-        ::arrow::field("variant_unshredded", arrow_variant, 
/*nullable=*/true));
-    auto arrow_schema = ::arrow::schema(arrow_fields);
+  // Arrow schema for unshredded variant struct.
+  auto arrow_metadata = ::arrow::field("metadata", ::arrow::binary(), 
/*nullable=*/false);
+  auto arrow_value = ::arrow::field("value", ::arrow::binary(), 
/*nullable=*/false);
+  auto arrow_variant = ::arrow::struct_({arrow_metadata, arrow_value});
+
+  // Register the variant extension type since it is not registered by default.
+  auto variant_extension = 
std::make_shared<VariantExtensionType>(arrow_variant);
+  ASSERT_OK(::arrow::ExtensionTypeRegistry::GetGlobalRegistry()->RegisterType(
+      variant_extension));

Review Comment:
   Can we use `ExtensionTypeGuard` to make sure the test restores the previous 
state when it finishes?



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to