rdblue commented on a change in pull request #2204:
URL: https://github.com/apache/iceberg/pull/2204#discussion_r572261588
##########
File path: core/src/test/java/org/apache/iceberg/TestSchemaUpdate.java
##########
@@ -488,19 +488,71 @@ public void testAmbiguousAdd() {
@Test
public void testAddAlreadyExists() {
AssertHelpers.assertThrows("Should reject column name that already exists",
- IllegalArgumentException.class, "already exists:
preferences.feature1", () -> {
+ IllegalArgumentException.class, "already exists and is not being
deleted: preferences.feature1", () -> {
UpdateSchema update = new SchemaUpdate(SCHEMA,
SCHEMA_LAST_COLUMN_ID);
update.addColumn("preferences", "feature1", Types.BooleanType.get());
}
);
AssertHelpers.assertThrows("Should reject column name that already exists",
- IllegalArgumentException.class, "already exists: preferences", () -> {
+ IllegalArgumentException.class, "already exists and is not being
deleted: preferences", () -> {
UpdateSchema update = new SchemaUpdate(SCHEMA,
SCHEMA_LAST_COLUMN_ID);
update.addColumn("preferences", Types.BooleanType.get());
}
);
}
+ @Test
+ public void testDeleteThenAdd() {
+ Schema schema = new Schema(required(1, "id", Types.IntegerType.get()));
+ Schema expected = new Schema(optional(2, "id", Types.IntegerType.get()));
+
+ Schema updated = new SchemaUpdate(schema, 1)
+ .deleteColumn("id")
+ .addColumn("id", optional(2, "id", Types.IntegerType.get()).type())
+ .apply();
+
+ Assert.assertEquals("Should match with added fields", expected.asStruct(),
updated.asStruct());
+
+ Schema expectedNested = new Schema(
Review comment:
Can you move the nested test into its own method? No need to mix the two.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]