leangjonathan commented on code in PR #10861: URL: https://github.com/apache/iceberg/pull/10861#discussion_r1704767712
########## 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: Combinatorial explosion for n choose 2 is small for reasonable values of n < 100. Modifying the upgrade test to check all potential upgrade paths -- 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