holdenk commented on a change in pull request #2048:
URL: https://github.com/apache/iceberg/pull/2048#discussion_r560426816
##########
File path: core/src/main/java/org/apache/iceberg/SchemaUpdate.java
##########
@@ -357,7 +357,14 @@ private void internalMove(String name, Move move) {
*/
@Override
public Schema apply() {
- return applyChanges(schema, deletes, updates, adds, moves);
+ Schema newSchema = applyChanges(schema, deletes, updates, adds, moves);
+
+ // Validate the metrics if we have existing properties.
+ if (base != null && base.properties() != null) {
+
MetricsConfig.fromProperties(base.properties()).validateReferencedColumns(newSchema);
+ }
+
+ return newSchema;
Review comment:
It is currently covered by `testModificationWithMetricsMetrics`,
commenting out the check results in the following error when running gradle
build:
```
org.apache.iceberg.TestSchemaAndMappingUpdate >
testModificationWithMetricsMetrics[formatVersion = 1] FAILED
java.lang.AssertionError: No exception was thrown (Deleting a column
with metrics fails), expected: org.apache.iceberg.exceptions.ValidationException
at org.junit.Assert.fail(Assert.java:88)
at
org.apache.iceberg.AssertHelpers.assertThrows(AssertHelpers.java:65)
at
org.apache.iceberg.TestSchemaAndMappingUpdate.testModificationWithMetricsMetrics(TestSchemaAndMappingUpdate.java:179)
org.apache.iceberg.TestSchemaAndMappingUpdate >
testModificationWithMetricsMetrics[formatVersion = 2] FAILED
java.lang.AssertionError: No exception was thrown (Deleting a column
with metrics fails), expected: org.apache.iceberg.exceptions.ValidationException
at org.junit.Assert.fail(Assert.java:88)
at
org.apache.iceberg.AssertHelpers.assertThrows(AssertHelpers.java:65)
at
org.apache.iceberg.TestSchemaAndMappingUpdate.testModificationWithMetricsMetrics(TestSchemaAndMappingUpdate.java:179)
```
----------------------------------------------------------------
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]