zhangbutao commented on code in PR #6482:
URL: https://github.com/apache/iceberg/pull/6482#discussion_r1089690531
##########
core/src/test/java/org/apache/iceberg/TestTableUpdatePartitionSpec.java:
##########
@@ -187,6 +188,53 @@ public void testRemoveAndAddField() {
Assert.assertEquals(1001, table.spec().lastAssignedFieldId());
}
+ @Test
+ public void testAddAfterRemoveTimeField() {
+ table.updateSpec().addField(year("year_field")).commit();
+
+ PartitionSpec newSpec = PartitionSpec.builderFor(table.schema())
+ .withSpecId(1)
+ .bucket("data", 16)
+ .year("year_field")
+ .build();
+
+ Assert.assertEquals(
+ "Should have same transform class:
org.apache.iceberg.transforms.Years",
+ newSpec.fields().get(1).transform().getClass().getName(),
+ table.spec().fields().get(1).transform().getClass().getName());
+
+ V1Assert.assertEquals("Should add a new id year", newSpec, table.spec());
+ V2Assert.assertEquals(
+ "Should add a new id year",
+ PartitionSpec.builderFor(table.schema())
+ .withSpecId(1)
+ .add(2, 1000, "data_bucket", Transforms.bucket(16))
+ .add(3, 1001, "year_field_year", Transforms.year())
+ .build(),
+ table.spec());
+
+ // remove and add a field with TimeTransform(Years, Months, Days, Hours)
+
table.updateSpec().removeField("year_field_year").addField(year("year_field")).commit();
+
+ V1Assert.assertEquals(
+ "Should remove and then add a year field",
+ PartitionSpec.builderFor(table.schema())
+ .withSpecId(1)
+ .bucket("data", 16)
+ .year("year_field")
+ .build(),
+ table.spec());
+ V2Assert.assertEquals(
Review Comment:
Oh, You mean `V1Assert.assertEquals` and `V2Assert.assertEquals`? I just
follow other tests pattern and i think there maybe have some difference bettewn
v2 and v1 formation, but i have not make more research.
--
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]