|
20 | 20 | #include "iceberg/update/update_schema.h" |
21 | 21 |
|
22 | 22 | #include <memory> |
| 23 | +#include <vector> |
23 | 24 |
|
24 | 25 | #include <gtest/gtest.h> |
25 | 26 |
|
|
29 | 30 | #include "iceberg/test/update_test_base.h" |
30 | 31 | #include "iceberg/type.h" |
31 | 32 | #include "iceberg/util/checked_cast.h" |
| 33 | +#include "iceberg/util/type_util.h" |
32 | 34 |
|
33 | 35 | namespace iceberg { |
34 | 36 |
|
@@ -1068,6 +1070,22 @@ TEST_F(UpdateSchemaTest, UpdateColumnUnknownToPrimitive) { |
1068 | 1070 | EXPECT_EQ(field_opt->get().doc(), "A null-only placeholder"); |
1069 | 1071 | } |
1070 | 1072 |
|
| 1073 | +TEST_F(UpdateSchemaTest, UpdateColumnPromotionToNestedTypesForbidden) { |
| 1074 | + std::vector<std::shared_ptr<Type>> nested_types = { |
| 1075 | + struct_({SchemaField::MakeOptional(3, "name", string())}), |
| 1076 | + list(SchemaField::MakeOptional(4, "element", string())), |
| 1077 | + map(SchemaField::MakeRequired(5, "key", string()), |
| 1078 | + SchemaField::MakeOptional(6, "value", string())), |
| 1079 | + }; |
| 1080 | + |
| 1081 | + for (const auto& nested_type : nested_types) { |
| 1082 | + SCOPED_TRACE(nested_type->ToString()); |
| 1083 | + |
| 1084 | + EXPECT_FALSE(IsPromotionAllowed(unknown(), nested_type)); |
| 1085 | + EXPECT_FALSE(IsPromotionAllowed(int32(), nested_type)); |
| 1086 | + } |
| 1087 | +} |
| 1088 | + |
1071 | 1089 | TEST_F(UpdateSchemaTest, AddRequiredUnknownColumnFails) { |
1072 | 1090 | ICEBERG_UNWRAP_OR_FAIL(auto update, table_->NewUpdateSchema()); |
1073 | 1091 | update->AllowIncompatibleChanges().AddRequiredColumn("mystery", unknown()); |
|
0 commit comments