RussellSpitzer commented on code in PR #10861: URL: https://github.com/apache/iceberg/pull/10861#discussion_r1703469879
########## core/src/test/java/org/apache/iceberg/TestTableMetadata.java: ########## @@ -1452,52 +1452,148 @@ public void testCreateV2MetadataThroughTableProperty() { } @Test - public void testReplaceV1MetadataToV2ThroughTableProperty() { + public void testReplaceMetadataThroughTableProperty() { Schema schema = new Schema(Types.NestedField.required(10, "x", Types.StringType.get())); - TableMetadata meta = - TableMetadata.newTableMetadata( - schema, - PartitionSpec.unpartitioned(), - null, - ImmutableMap.of(TableProperties.FORMAT_VERSION, "1", "key", "val")); - - meta = - meta.buildReplacement( - meta.schema(), - meta.spec(), - meta.sortOrder(), - meta.location(), - ImmutableMap.of(TableProperties.FORMAT_VERSION, "2", "key2", "val2")); - - assertThat(meta.formatVersion()).isEqualTo(2); - assertThat(meta.properties()) - .containsEntry("key", "val") - .containsEntry("key2", "val2") - .doesNotContainKey(TableProperties.FORMAT_VERSION); + for (int baseTableVersion = 1; + baseTableVersion < TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION; + baseTableVersion++) { + TableMetadata meta = + TableMetadata.newTableMetadata( + schema, + PartitionSpec.unpartitioned(), + null, + ImmutableMap.of( + TableProperties.FORMAT_VERSION, String.valueOf(baseTableVersion), "key", "val")); + + int newTableVersion = baseTableVersion + 1; + meta = + meta.buildReplacement( + meta.schema(), + meta.spec(), + meta.sortOrder(), + meta.location(), + ImmutableMap.of( + TableProperties.FORMAT_VERSION, String.valueOf(newTableVersion), "key2", "val2")); + + assertThat(meta.formatVersion()).isEqualTo(newTableVersion); + assertThat(meta.properties()) + .containsEntry("key", "val") + .containsEntry("key2", "val2") + .doesNotContainKey(TableProperties.FORMAT_VERSION); + } } @Test - public void testUpgradeV1MetadataToV2ThroughTableProperty() { - Schema schema = new Schema(Types.NestedField.required(10, "x", Types.StringType.get())); - - TableMetadata meta = - TableMetadata.newTableMetadata( - schema, - PartitionSpec.unpartitioned(), - null, - ImmutableMap.of(TableProperties.FORMAT_VERSION, "1", "key", "val")); + public void testReplaceMetadataThroughTablePropertySkipVersion() { Review Comment: I think this probably (for forward looking things) shouldn't be doing a single skip but should be testing all upgrades to the newest one or if we want to keep the combinatorial explosion to a minimum just upgrades to the latest version. Ie if we had 5 versions we could either do all the versions: ``` 1 -> 2 1 -> 3 1 -> 4 1 -> 5 2 -> 3 2 -> 4 ... 4 -> 5 ``` Or just do the jump to the latest: ``` 1 -> 5 2 -> 5 3 -> 5 4 -> 5 ``` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org