nullccxsy commented on code in PR #180:
URL: https://github.com/apache/iceberg-cpp/pull/180#discussion_r2295501481
##########
test/schema_test.cc:
##########
@@ -81,3 +81,260 @@ TEST(SchemaTest, Equality) {
ASSERT_EQ(schema1, schema5);
ASSERT_EQ(schema5, schema1);
}
+
+class NestedTypeTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ field1_ = iceberg::SchemaField(1, "Foo", iceberg::int32(), true);
+ field2_ = iceberg::SchemaField(2, "Bar", iceberg::string(), true);
+ field3_ = iceberg::SchemaField(3, "Foobar", iceberg::int32(), true);
+
+ iceberg::StructType structtype =
+ iceberg::StructType(std::vector<iceberg::SchemaField>{
+ field1_.value(), field2_.value(), field3_.value()});
+
+ auto listype = iceberg::ListType(iceberg::SchemaField::MakeRequired(
+ 4, "element", std::make_shared<iceberg::StructType>(structtype)));
+
+ auto maptype =
+ iceberg::MapType(iceberg::SchemaField::MakeRequired(5, "key",
iceberg::int32()),
+ iceberg::SchemaField::MakeRequired(
+ 6, "value",
std::make_shared<iceberg::ListType>(listype)));
+
+ field4_ = iceberg::SchemaField::MakeRequired(
+ 4, "element", std::make_shared<iceberg::StructType>(structtype));
+ field5_ = iceberg::SchemaField::MakeRequired(5, "key", iceberg::int32());
+ field6_ = iceberg::SchemaField::MakeRequired(
+ 6, "value", std::make_shared<iceberg::ListType>(listype));
+ field7_ = iceberg::SchemaField::MakeRequired(
+ 7, "Value", std::make_shared<iceberg::MapType>(maptype));
+
+ schema_ = std::make_shared<iceberg::Schema>(
+ std::vector<iceberg::SchemaField>{field7_.value()}, 1);
+ }
+
+ std::shared_ptr<iceberg::Schema> schema_;
+ std::optional<iceberg::SchemaField> field1_;
+ std::optional<iceberg::SchemaField> field2_;
+ std::optional<iceberg::SchemaField> field3_;
+ std::optional<iceberg::SchemaField> field4_;
+ std::optional<iceberg::SchemaField> field5_;
+ std::optional<iceberg::SchemaField> field6_;
+ std::optional<iceberg::SchemaField> field7_;
+};
Review Comment:
No, SchemaField don't have default construct funciton with no parms , so we
use ```
```
std::optional<iceberg::SchemaField>
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]