rdblue commented on a change in pull request #2048:
URL: https://github.com/apache/iceberg/pull/2048#discussion_r556074846



##########
File path: core/src/test/java/org/apache/iceberg/TestSchemaAndMappingUpdate.java
##########
@@ -155,6 +156,42 @@ public void testDeleteColumn() {
     validateUnchanged(mapping, updated);
   }
 
+  @Test
+  public void testModificationWithMetricsMetrics() {
+    NameMapping mapping = MappingUtil.create(table.schema());
+    String mappingJson = NameMappingParser.toJson(mapping);
+
+    table.updateProperties()
+        .set(TableProperties.DEFAULT_NAME_MAPPING, mappingJson)
+        .set("write.metadata.metrics.column.id", "full")
+        .commit();
+
+    AssertHelpers.assertThrows(
+        "Creating metrics for non-existent column fails",
+        ValidationException.class,
+        null,
+        () ->
+          table.updateProperties()
+            .set(TableProperties.DEFAULT_NAME_MAPPING, mappingJson)
+            .set("write.metadata.metrics.column.ids", "full")
+          .commit());
+
+    AssertHelpers.assertThrows(
+        "Deleting a column with metrics fails",
+        ValidationException.class,
+        null,
+        () ->
+          table.updateSchema()
+              .deleteColumn("id")
+          .commit());
+
+    String updatedJson = 
table.properties().get(TableProperties.DEFAULT_NAME_MAPPING);
+    NameMapping updated = NameMappingParser.fromJson(updatedJson);
+
+    // should not change the mapping
+    validateUnchanged(mapping, updated);

Review comment:
       It seems strange to me that this would be tested in the suite for the 
schema mapping. This should be independent of mapping. While it is okay to have 
a test that a mapping is not updated if the validation fails, that should be 
covered by not updating the schema if metrics property validation fails. Could 
you start a new suite similar to `TestSchemaAndMappingUpdate` for this instead 
of adding the tests here?




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

Reply via email to