770120041 commented on code in PR #15552:
URL: https://github.com/apache/iceberg/pull/15552#discussion_r2905766365


##########
core/src/test/java/org/apache/iceberg/TestSchemaUpdate.java:
##########
@@ -1181,6 +1181,34 @@ public void testDeleteMapKey() {
         .hasMessageStartingWith("Cannot delete map keys");
   }
 
+  @Test
+  public void testDeleteMapColumn() {
+    // Deleting an entire map column should succeed
+    Schema updated =
+        new SchemaUpdate(SCHEMA, 
SCHEMA_LAST_COLUMN_ID).deleteColumn("locations").apply();
+    assertThat(updated.findField("locations")).isNull();
+  }
+
+  @Test
+  public void testDeleteSimpleMapColumn() {
+    // Deleting a simple map<string, string> column should succeed
+    Schema updated =
+        new SchemaUpdate(SCHEMA, 
SCHEMA_LAST_COLUMN_ID).deleteColumn("properties").apply();
+    assertThat(updated.findField("properties")).isNull();
+  }
+
+  @Test
+  public void testDeleteMapValue() {
+    // Deleting a map's value field should fail
+    assertThatThrownBy(
+            () ->
+                new SchemaUpdate(SCHEMA, SCHEMA_LAST_COLUMN_ID)
+                    .deleteColumn("locations.value")
+                    .apply())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot delete value type from map");
+  }

Review Comment:
   Thanks for the review @ebyhr ! I checked again and I think you're right. I 
investigated and confirmed that deleting map columns already works on `main`, 
since `deleteColumn("locations")` adds the parent field ID (e.g., 4) to 
`deletes`, but `map()` checks `deletes.contains(keyId)` where keyId is always a 
different unique ID (e.g., 10), so they never collide.
   
   I've updated this PR to remove the `SchemaUpdate.java` change and keep only 
the tests as regression guards if needed. If we don't need those extra tests I 
can also close this PR 
   



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