Apache Iceberg version
None
Query engine
None
Please describe the bug 🐞
The test in #14334 uncovered an edge case where the same view change is applied twice and fails with
org.apache.iceberg.exceptions.ValidationException: Cannot set last added schema: no schema has been added
at org.apache.iceberg.exceptions.ValidationException.check(ValidationException.java:49)
at org.apache.iceberg.view.ViewMetadata$Builder.addVersionInternal(ViewMetadata.java:297)
at org.apache.iceberg.view.ViewMetadata$Builder.addVersion(ViewMetadata.java:277)
at org.apache.iceberg.MetadataUpdate$AddViewVersion.applyTo(MetadataUpdate.java:508)
at org.apache.iceberg.rest.CatalogHandlers.lambda$commit$11(CatalogHandlers.java:624)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.apache.iceberg.rest.CatalogHandlers.lambda$commit$12(CatalogHandlers.java:624)
This is due to our internal state tracking of lastAddedSchemaId, which is then assumed to be set when adding the view version and checking
if (version.schemaId() == LAST_ADDED) {
ValidationException.check(lastAddedSchemaId != null, "Cannot set last added schema: no schema has been added");
version = ImmutableViewVersion.builder().from(version).schemaId(lastAddedSchemaId).build();
}
Willingness to contribute
Apache Iceberg version
None
Query engine
None
Please describe the bug 🐞
The test in #14334 uncovered an edge case where the same view change is applied twice and fails with
This is due to our internal state tracking of
lastAddedSchemaId, which is then assumed to be set when adding the view version and checkingWillingness to contribute