pitrou commented on code in PR #49218:
URL: https://github.com/apache/arrow/pull/49218#discussion_r2792010061
##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -2018,6 +2019,50 @@ TEST_F(TestConvertRoundTrip,
FieldIdPreserveAllColumnTypes) {
ASSERT_EQ(thrift_field_ids, expected_field_ids);
}
+TEST_F(TestConvertRoundTrip, MapNestedFieldMetadataPreserved) {
+ auto key_meta = ::arrow::key_value_metadata({"k"}, {"v"});
+ auto inner_meta = ::arrow::key_value_metadata({"inner_k"}, {"inner_v"});
+
+ auto map_key = ::arrow::field("key", UTF8, /*nullable=*/false, key_meta);
+ auto map_value = ::arrow::field(
+ "value",
+ ::arrow::struct_({::arrow::field("inner", INT64, /*nullable=*/true,
inner_meta)}),
+ /*nullable=*/true, inner_meta);
+ auto sorted_map =
+ std::make_shared<::arrow::MapType>(map_key, map_value,
/*keys_sorted=*/true);
+ auto arrow_schema = ::arrow::schema(
+ {::arrow::field("m", sorted_map, /*nullable=*/true,
FieldIdMetadata(99))});
+
+ std::shared_ptr<SchemaDescriptor> parquet_schema;
+ ASSERT_OK(ToParquetSchema(arrow_schema.get(),
*::parquet::default_writer_properties(),
+ &parquet_schema));
+
+ std::shared_ptr<KeyValueMetadata> kv_metadata;
+ ASSERT_OK(ArrowSchemaToParquetMetadata(arrow_schema, kv_metadata));
+
+ std::shared_ptr<::arrow::Schema> restored_schema;
+ ASSERT_OK(FromParquetSchema(parquet_schema.get(), ArrowReaderProperties(),
kv_metadata,
+ &restored_schema));
+ ASSERT_EQ(restored_schema->num_fields(), 1);
+
+ auto restored_map =
::arrow::internal::checked_pointer_cast<::arrow::MapType>(
+ restored_schema->field(0)->type());
+ ASSERT_EQ(GetFieldId(*restored_schema->field(0)), 99);
+
+ ASSERT_TRUE(restored_map->keys_sorted());
Review Comment:
Can we just call `AssertTypeEqual(*sorted_map, *restored_map,
/*check_metadata=*/true);`?
It doesn't seem useful to spelunk the nested type hierarchy manually.
--
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]