@@ -1870,7 +1870,7 @@ class TestSchemaImport : public ::testing::Test, public SchemaStructBuilder {
1870
1870
ASSERT_TRUE (ArrowSchemaIsReleased (&c_struct_));
1871
1871
Reset (); // for further tests
1872
1872
cb.AssertCalled (); // was released
1873
- AssertTypeEqual (*expected, *type);
1873
+ AssertTypeEqual (*expected, *type, /* check_metadata= */ true );
1874
1874
}
1875
1875
1876
1876
void CheckImport (const std::shared_ptr<Field>& expected) {
@@ -1890,7 +1890,7 @@ class TestSchemaImport : public ::testing::Test, public SchemaStructBuilder {
1890
1890
ASSERT_TRUE (ArrowSchemaIsReleased (&c_struct_));
1891
1891
Reset (); // for further tests
1892
1892
cb.AssertCalled (); // was released
1893
- AssertSchemaEqual (*expected, *schema);
1893
+ AssertSchemaEqual (*expected, *schema, /* check_metadata= */ true );
1894
1894
}
1895
1895
1896
1896
void CheckImportError () {
@@ -3569,7 +3569,7 @@ class TestSchemaRoundtrip : public ::testing::Test {
3569
3569
// Recreate the type
3570
3570
ASSERT_OK_AND_ASSIGN (actual, ImportType (&c_schema));
3571
3571
type = factory_expected ();
3572
- AssertTypeEqual (*type, *actual);
3572
+ AssertTypeEqual (*type, *actual, /* check_metadata= */ true );
3573
3573
type.reset ();
3574
3574
actual.reset ();
3575
3575
@@ -3600,7 +3600,7 @@ class TestSchemaRoundtrip : public ::testing::Test {
3600
3600
// Recreate the schema
3601
3601
ASSERT_OK_AND_ASSIGN (actual, ImportSchema (&c_schema));
3602
3602
schema = factory ();
3603
- AssertSchemaEqual (*schema, *actual);
3603
+ AssertSchemaEqual (*schema, *actual, /* check_metadata= */ true );
3604
3604
schema.reset ();
3605
3605
actual.reset ();
3606
3606
@@ -3693,13 +3693,23 @@ TEST_F(TestSchemaRoundtrip, Dictionary) {
3693
3693
}
3694
3694
}
3695
3695
3696
+ std::shared_ptr<Field> GetStorageWithMetadata (const std::string& field_name,
3697
+ const std::shared_ptr<DataType>& type) {
3698
+ const auto & ext_type = checked_cast<const ExtensionType&>(*type);
3699
+ auto storage_type = ext_type.storage_type ();
3700
+ auto md = KeyValueMetadata::Make ({kExtensionTypeKeyName , kExtensionMetadataKeyName },
3701
+ {ext_type.extension_name (), ext_type.Serialize ()});
3702
+ return field (field_name, storage_type, /* nullable=*/ true , md);
3703
+ }
3704
+
3696
3705
TEST_F (TestSchemaRoundtrip, UnregisteredExtension) {
3697
3706
TestWithTypeFactory (uuid, []() { return fixed_size_binary (16 ); });
3698
3707
TestWithTypeFactory (dict_extension_type, []() { return dictionary (int8 (), utf8 ()); });
3699
3708
3700
3709
// Inside nested type
3701
- TestWithTypeFactory ([]() { return list (dict_extension_type ()); },
3702
- []() { return list (dictionary (int8 (), utf8 ())); });
3710
+ TestWithTypeFactory (
3711
+ []() { return list (dict_extension_type ()); },
3712
+ []() { return list (GetStorageWithMetadata (" item" , dict_extension_type ())); });
3703
3713
}
3704
3714
3705
3715
TEST_F (TestSchemaRoundtrip, RegisteredExtension) {
@@ -3808,7 +3818,7 @@ class TestArrayRoundtrip : public ::testing::Test {
3808
3818
{
3809
3819
std::shared_ptr<Array> expected;
3810
3820
ASSERT_OK_AND_ASSIGN (expected, ToResult (factory_expected ()));
3811
- AssertTypeEqual (*expected->type (), *array->type ());
3821
+ AssertTypeEqual (*expected->type (), *array->type (), /* check_metadata= */ true );
3812
3822
AssertArraysEqual (*expected, *array, true );
3813
3823
}
3814
3824
array.reset ();
@@ -3848,7 +3858,7 @@ class TestArrayRoundtrip : public ::testing::Test {
3848
3858
{
3849
3859
std::shared_ptr<RecordBatch> expected;
3850
3860
ASSERT_OK_AND_ASSIGN (expected, ToResult (factory ()));
3851
- AssertSchemaEqual (*expected->schema (), *batch->schema ());
3861
+ AssertSchemaEqual (*expected->schema (), *batch->schema (), /* check_metadata= */ true );
3852
3862
AssertBatchesEqual (*expected, *batch);
3853
3863
}
3854
3864
batch.reset ();
@@ -4228,7 +4238,7 @@ class TestDeviceArrayRoundtrip : public ::testing::Test {
4228
4238
{
4229
4239
std::shared_ptr<Array> expected;
4230
4240
ASSERT_OK_AND_ASSIGN (expected, ToResult (factory_expected ()));
4231
- AssertTypeEqual (*expected->type (), *array->type ());
4241
+ AssertTypeEqual (*expected->type (), *array->type (), /* check_metadata= */ true );
4232
4242
AssertArraysEqual (*expected, *array, true );
4233
4243
}
4234
4244
array.reset ();
@@ -4274,7 +4284,7 @@ class TestDeviceArrayRoundtrip : public ::testing::Test {
4274
4284
{
4275
4285
std::shared_ptr<RecordBatch> expected;
4276
4286
ASSERT_OK_AND_ASSIGN (expected, ToResult (factory ()));
4277
- AssertSchemaEqual (*expected->schema (), *batch->schema ());
4287
+ AssertSchemaEqual (*expected->schema (), *batch->schema (), /* check_metadata= */ true );
4278
4288
AssertBatchesEqual (*expected, *batch);
4279
4289
}
4280
4290
batch.reset ();
@@ -4351,7 +4361,7 @@ class TestArrayStreamExport : public BaseArrayStreamTest {
4351
4361
SchemaExportGuard schema_guard (&c_schema);
4352
4362
ASSERT_FALSE (ArrowSchemaIsReleased (&c_schema));
4353
4363
ASSERT_OK_AND_ASSIGN (auto schema, ImportSchema (&c_schema));
4354
- AssertSchemaEqual (expected, *schema);
4364
+ AssertSchemaEqual (expected, *schema, /* check_metadata= */ true );
4355
4365
}
4356
4366
4357
4367
void AssertStreamEnd (struct ArrowArrayStream * c_stream) {
@@ -4435,7 +4445,7 @@ TEST_F(TestArrayStreamExport, ArrayLifetime) {
4435
4445
{
4436
4446
SchemaExportGuard schema_guard (&c_schema);
4437
4447
ASSERT_OK_AND_ASSIGN (auto got_schema, ImportSchema (&c_schema));
4438
- AssertSchemaEqual (*schema, *got_schema);
4448
+ AssertSchemaEqual (*schema, *got_schema, /* check_metadata= */ true );
4439
4449
}
4440
4450
4441
4451
ASSERT_GT (pool_->bytes_allocated (), orig_allocated_);
@@ -4460,7 +4470,7 @@ TEST_F(TestArrayStreamExport, Errors) {
4460
4470
{
4461
4471
SchemaExportGuard schema_guard (&c_schema);
4462
4472
ASSERT_OK_AND_ASSIGN (auto schema, ImportSchema (&c_schema));
4463
- AssertSchemaEqual (schema, arrow::schema ({}));
4473
+ AssertSchemaEqual (schema, arrow::schema ({}), /* check_metadata= */ true );
4464
4474
}
4465
4475
4466
4476
struct ArrowArray c_array;
@@ -4537,7 +4547,7 @@ TEST_F(TestArrayStreamRoundtrip, Simple) {
4537
4547
ASSERT_OK_AND_ASSIGN (auto reader, RecordBatchReader::Make (batches, orig_schema));
4538
4548
4539
4549
Roundtrip (std::move (reader), [&](const std::shared_ptr<RecordBatchReader>& reader) {
4540
- AssertSchemaEqual (*orig_schema, *reader->schema ());
4550
+ AssertSchemaEqual (*orig_schema, *reader->schema (), /* check_metadata= */ true );
4541
4551
AssertReaderNext (reader, *batches[0 ]);
4542
4552
AssertReaderNext (reader, *batches[1 ]);
4543
4553
AssertReaderEnd (reader);
0 commit comments