MCPcopy Create free account
hub / github.com/apache/arrow / DoNestedRequiredRoundtrip

Function DoNestedRequiredRoundtrip

cpp/src/parquet/arrow/arrow_reader_writer_test.cc:3708–3742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3706}
3707
3708void DoNestedRequiredRoundtrip(
3709 const std::shared_ptr<::arrow::DataType>& inner_type,
3710 const std::shared_ptr<WriterProperties>& writer_properties,
3711 const std::shared_ptr<ArrowWriterProperties>& arrow_writer_properties) {
3712 // Test ARROW-15961/ARROW-16116
3713 ARROW_SCOPED_TRACE("Type: ", inner_type->ToString());
3714 std::shared_ptr<::arrow::KeyValueMetadata> metadata;
3715 if (inner_type->id() != ::arrow::Type::DICTIONARY) {
3716 metadata = ::arrow::key_value_metadata({{"min", "0"}, {"max", "127"}});
3717 }
3718 auto inner_field =
3719 ::arrow::field("inner", inner_type, /*nullable=*/false, std::move(metadata));
3720 auto type = ::arrow::struct_({inner_field});
3721 auto field = ::arrow::field("outer", type, /*nullable=*/true);
3722
3723 auto gen = ::arrow::random::RandomArrayGenerator(/*seed=*/42);
3724 auto inner = gen.ArrayOf(*inner_field, /*size=*/4);
3725 ASSERT_EQ(inner->null_count(), 0) << inner->ToString();
3726
3727 ::arrow::TypedBufferBuilder<bool> bitmap_builder;
3728 ASSERT_OK(bitmap_builder.Append(2, false));
3729 ASSERT_OK(bitmap_builder.Append(2, true));
3730 ASSERT_OK_AND_ASSIGN(auto null_bitmap, bitmap_builder.Finish());
3731 ASSERT_OK_AND_ASSIGN(auto array,
3732 ::arrow::StructArray::Make({inner}, {inner_field}, null_bitmap));
3733 auto table = ::arrow::Table::Make(::arrow::schema({field}), {array});
3734 ASSERT_OK(table->ValidateFull());
3735
3736 auto sink = CreateOutputStream();
3737 ASSERT_OK_NO_THROW(WriteTable(*table, ::arrow::default_memory_pool(), sink,
3738 /*row_group_size=*/4, writer_properties,
3739 arrow_writer_properties));
3740 ASSERT_OK_AND_ASSIGN(auto buffer, sink->Finish());
3741 ASSERT_NO_FATAL_FAILURE(DoNestedValidate(inner_type, field, buffer, table));
3742}
3743
3744TEST(ArrowReadWrite, NestedRequiredOuterOptional) {
3745 std::vector<std::shared_ptr<DataType>> types = ::arrow::PrimitiveTypes();

Callers 1

TESTFunction · 0.85

Calls 15

key_value_metadataFunction · 0.85
struct_Function · 0.85
CreateOutputStreamFunction · 0.85
default_memory_poolFunction · 0.85
DoNestedValidateFunction · 0.85
fieldFunction · 0.70
WriteTableFunction · 0.70
MakeFunction · 0.50
schemaFunction · 0.50
ToStringMethod · 0.45
idMethod · 0.45
ArrayOfMethod · 0.45

Tested by

no test coverage detected