aihuaxu commented on code in PR #47835:
URL: https://github.com/apache/arrow/pull/47835#discussion_r2437453254


##########
cpp/src/parquet/schema_test.cc:
##########
@@ -2353,6 +2353,32 @@ TEST(TestLogicalTypeSerialization, Roundtrips) {
   // Group nodes ...
   ConfirmGroupNodeRoundtrip("map", LogicalType::Map());
   ConfirmGroupNodeRoundtrip("list", LogicalType::List());
+  ConfirmGroupNodeRoundtrip("variant", LogicalType::Variant());
+}
+
+TEST(TestLogicalTypeSerialization, VariantSpecificationVersion) {
+  // Confirm that Variant logical type sets specification_version to 1 in 
thrift serialization
+   auto metadata = PrimitiveNode::Make("metadata", Repetition::REQUIRED, 
Type::BYTE_ARRAY);
+  auto value = PrimitiveNode::Make("value", Repetition::REQUIRED, 
Type::BYTE_ARRAY);
+  NodePtr variant_node = GroupNode::Make("variant", Repetition::REQUIRED, 
{metadata, value},
+                                         LogicalType::Variant());
+
+  std::vector<format::SchemaElement> elements;
+  ToParquet(reinterpret_cast<GroupNode*>(variant_node.get()), &elements);
+
+  // Verify that logicalType is set and is VARIANT
+  ASSERT_EQ(elements[0].name, "variant");
+  ASSERT_TRUE(elements[0].__isset.logicalType)
+      << "Variant logical type failed to generate a logicalType in thrift";
+  ASSERT_TRUE(elements[0].logicalType.__isset.VARIANT)
+      << "Variant logical type did not set VARIANT field in thrift";
+
+  // Verify that specification_version is set to 1
+  ASSERT_TRUE(elements[0].logicalType.VARIANT.__isset.specification_version)
+      << "VariantType specification_version field is not set";
+  ASSERT_EQ(elements[0].logicalType.VARIANT.specification_version, 1)
+      << "VariantType specification_version should be 1, got: "
+      << 
static_cast<int>(elements[0].logicalType.VARIANT.specification_version);

Review Comment:
   Make sense. I removed it to simplify.



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