| 3600 | } |
| 3601 | |
| 3602 | void DoNestedRequiredRoundtrip( |
| 3603 | const std::shared_ptr<::arrow::DataType>& inner_type, |
| 3604 | const std::shared_ptr<WriterProperties>& writer_properties, |
| 3605 | const std::shared_ptr<ArrowWriterProperties>& arrow_writer_properties) { |
| 3606 | // Test ARROW-15961/ARROW-16116 |
| 3607 | ARROW_SCOPED_TRACE("Type: ", inner_type->ToString()); |
| 3608 | std::shared_ptr<::arrow::KeyValueMetadata> metadata; |
| 3609 | if (inner_type->id() != ::arrow::Type::DICTIONARY) { |
| 3610 | metadata = ::arrow::key_value_metadata({{"min", "0"}, {"max", "127"}}); |
| 3611 | } |
| 3612 | auto inner_field = |
| 3613 | ::arrow::field("inner", inner_type, /*nullable=*/false, std::move(metadata)); |
| 3614 | auto type = ::arrow::struct_({inner_field}); |
| 3615 | auto field = ::arrow::field("outer", type, /*nullable=*/true); |
| 3616 | |
| 3617 | auto gen = ::arrow::random::RandomArrayGenerator(/*seed=*/42); |
| 3618 | auto inner = gen.ArrayOf(*inner_field, /*size=*/4); |
| 3619 | ASSERT_EQ(inner->null_count(), 0) << inner->ToString(); |
| 3620 | |
| 3621 | ::arrow::TypedBufferBuilder<bool> bitmap_builder; |
| 3622 | ASSERT_OK(bitmap_builder.Append(2, false)); |
| 3623 | ASSERT_OK(bitmap_builder.Append(2, true)); |
| 3624 | ASSERT_OK_AND_ASSIGN(auto null_bitmap, bitmap_builder.Finish()); |
| 3625 | ASSERT_OK_AND_ASSIGN(auto array, |
| 3626 | ::arrow::StructArray::Make({inner}, {inner_field}, null_bitmap)); |
| 3627 | auto table = ::arrow::Table::Make(::arrow::schema({field}), {array}); |
| 3628 | ASSERT_OK(table->ValidateFull()); |
| 3629 | |
| 3630 | auto sink = CreateOutputStream(); |
| 3631 | ASSERT_OK_NO_THROW(WriteTable(*table, ::arrow::default_memory_pool(), sink, |
| 3632 | /*row_group_size=*/4, writer_properties, |
| 3633 | arrow_writer_properties)); |
| 3634 | ASSERT_OK_AND_ASSIGN(auto buffer, sink->Finish()); |
| 3635 | ASSERT_NO_FATAL_FAILURE(DoNestedValidate(inner_type, field, buffer, table)); |
| 3636 | } |
| 3637 | |
| 3638 | TEST(ArrowReadWrite, NestedRequiredOuterOptional) { |
| 3639 | std::vector<std::shared_ptr<DataType>> types = ::arrow::PrimitiveTypes(); |
no test coverage detected