Skip to content

Commit d2a34b5

Browse files
manuzhangcodex
andcommitted
test: cover forbidden nested type promotions
Assert that promotion helpers reject nested type targets for unknown and regular primitive source types. Co-authored-by: Codex <codex@openai.com>
1 parent 8087ed1 commit d2a34b5

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/iceberg/test/update_schema_test.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "iceberg/update/update_schema.h"
2121

2222
#include <memory>
23+
#include <vector>
2324

2425
#include <gtest/gtest.h>
2526

@@ -29,6 +30,7 @@
2930
#include "iceberg/test/update_test_base.h"
3031
#include "iceberg/type.h"
3132
#include "iceberg/util/checked_cast.h"
33+
#include "iceberg/util/type_util.h"
3234

3335
namespace iceberg {
3436

@@ -1068,6 +1070,22 @@ TEST_F(UpdateSchemaTest, UpdateColumnUnknownToPrimitive) {
10681070
EXPECT_EQ(field_opt->get().doc(), "A null-only placeholder");
10691071
}
10701072

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+
10711089
TEST_F(UpdateSchemaTest, AddRequiredUnknownColumnFails) {
10721090
ICEBERG_UNWRAP_OR_FAIL(auto update, table_->NewUpdateSchema());
10731091
update->AllowIncompatibleChanges().AddRequiredColumn("mystery", unknown());

0 commit comments

Comments
 (0)