zhangbutao commented on code in PR #6482:
URL: https://github.com/apache/iceberg/pull/6482#discussion_r1089692854


##########
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();

Review Comment:
   I don't think we need this case. Other tests have include the case, eg. 
`testAddAfterLastFieldRemoved`



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to