nastra commented on code in PR #14997:
URL: https://github.com/apache/iceberg/pull/14997#discussion_r2672490061
##########
core/src/test/java/org/apache/iceberg/view/TestViewMetadata.java:
##########
@@ -995,6 +995,40 @@ public void
deduplicatingViewVersionByIdAndAssigningSchemaId() {
assertThat(metadata.currentVersion().schemaId()).isEqualTo(1);
}
+ @Test
+ public void applySameViewVersionAndSchemaUpdateWithSchemaIdAssignment() {
+ Schema schema = new Schema(Types.NestedField.required(-1, "x",
Types.LongType.get()));
+ ViewVersion viewVersion = newViewVersion(1, -1, "select * from ns.tbl");
+ ViewMetadata metadata =
+ ViewMetadata.builder()
+ .setLocation("custom-location")
+ .addSchema(schema)
+ .addVersion(viewVersion)
+ .setCurrentVersionId(1)
+ .build();
+ assertThat(metadata.versions()).hasSize(1);
+ assertThat(metadata.currentVersion().versionId()).isEqualTo(1);
+ assertThat(metadata.currentVersion().schemaId()).isEqualTo(0);
+
+ // simulates a case where the same view update is applied twice and the
schema ID is set to -1
+ // (indicating that the schema ID should be automatically assigned)
+ // this scenario can happen with concurrent updates in REST cases where
the same update is
+ // applied twice. The view version gets a new ID assigned because
+ // ViewMetadata#sameViewVersion(current, updated) isn't true, because the
current's schemaId was
Review Comment:
we should probably deduplicate this properly. I'm working on a fix for this
--
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]