CodingCat commented on a change in pull request #3632:
URL: https://github.com/apache/iceberg/pull/3632#discussion_r773641941



##########
File path: core/src/test/java/org/apache/iceberg/TestUpdatePartitionSpec.java
##########
@@ -614,6 +605,65 @@ public void testRemoveAndAddMultiTimes() {
     V2Assert.assertEquals("Should match expected spec", v2Expected, updated);
   }
 
+  @Test
+  public void testRemoveAndUpdateWithIdentity() {

Review comment:
       Hi, @rdblue I know this is kind of a behavior change in iceberg, but I 
am wondering what is the benefit for the previous behavior ?
   
   I just found it convenient for us to lift the original restriction as we can 
blindly remove conflicted column names and add new instead of adding more 
checks if no significant benefit there 

##########
File path: core/src/test/java/org/apache/iceberg/TestUpdatePartitionSpec.java
##########
@@ -614,6 +605,65 @@ public void testRemoveAndAddMultiTimes() {
     V2Assert.assertEquals("Should match expected spec", v2Expected, updated);
   }
 
+  @Test
+  public void testRemoveAndUpdateWithIdentity() {
+    PartitionSpec expected = PartitionSpec.builderFor(SCHEMA)
+         .identity("ts")
+         .build();
+    PartitionSpec updated = new BaseUpdatePartitionSpec(formatVersion, 
expected)
+         .removeField("ts")
+         .addField("ts")
+         .apply();
+
+    if (formatVersion == 1) {
+      Assert.assertEquals("Should match expected spec field size", 2, 
updated.fields().size());
+      Assert.assertEquals("Should match expected field name", "ts_1000",
+              updated.fields().get(0).name());
+      Assert.assertEquals("Should match expected field name", "ts",
+              updated.fields().get(1).name());
+      Assert.assertEquals("Should match expected field transform", "void",
+              updated.fields().get(0).transform().toString());
+      Assert.assertEquals("Should match expected field transform", "identity",
+              updated.fields().get(1).transform().toString());
+    } else {
+      Assert.assertEquals("Should match expected spec field size", 1, 
updated.fields().size());
+      Assert.assertEquals("Should match expected field name", "ts",
+              updated.fields().get(0).name());
+      Assert.assertEquals("Should match expected field transform", "identity",
+              updated.fields().get(0).transform().toString());
+    }
+  }
+
+  @Test
+  public void testRemoveAndUpdateWithDifferentTransformation() {
+    PartitionSpec expected = PartitionSpec.builderFor(SCHEMA)
+        .month("ts", "ts_transformed")
+        .build();
+    PartitionSpec updated = new BaseUpdatePartitionSpec(formatVersion, 
expected)
+        .removeField("ts_transformed")
+        .addField("ts_transformed", day("ts"))
+        .apply();
+
+    if (formatVersion == 1) {
+      Assert.assertEquals("Should match expected spec field size", 2, 
updated.fields().size());

Review comment:
       Hi, @rdblue thanks for the review, I think the problem with 
V1Assert/V2Assert here is that we still need to check the length of 
updated.fields for different versions of format
   
   maybe checking version format is the most straightforward way like 
[here](https://github.com/apache/iceberg/blob/57bdf0ba61b10944f5fa6045cc32e321e90eb746/core/src/test/java/org/apache/iceberg/TestUpdatePartitionSpec.java#L584)




-- 
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]

Reply via email to