nastra commented on code in PR #10861:
URL: https://github.com/apache/iceberg/pull/10861#discussion_r1705025435


##########
core/src/test/java/org/apache/iceberg/TestTableMetadata.java:
##########
@@ -1451,50 +1457,67 @@ public void testCreateV2MetadataThroughTableProperty() {
         .doesNotContainKey(TableProperties.FORMAT_VERSION);
   }
 
-  @Test
-  public void testReplaceV1MetadataToV2ThroughTableProperty() {
+  private static Stream<Arguments> upgradeTableVersionProvider() {
+    // return a stream of all valid upgrade paths
+    return IntStream.range(1, TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION)
+        .boxed()
+        .flatMap(
+            baseTableVersion ->
+                IntStream.rangeClosed(
+                        baseTableVersion + 1, 
TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION)
+                    .mapToObj(newTableVersion -> arguments(baseTableVersion, 
newTableVersion)));
+  }
+
+  @ParameterizedTest
+  @MethodSource("upgradeTableVersionProvider")
+  public void testReplaceMetadataThroughTableProperty(int baseTableVersion, 
int newTableVersion) {
     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"));
+            ImmutableMap.of(
+                TableProperties.FORMAT_VERSION, 
String.valueOf(baseTableVersion), "key", "val"));
 
     meta =
         meta.buildReplacement(
             meta.schema(),
             meta.spec(),
             meta.sortOrder(),
             meta.location(),
-            ImmutableMap.of(TableProperties.FORMAT_VERSION, "2", "key2", 
"val2"));
+            ImmutableMap.of(
+                TableProperties.FORMAT_VERSION, 
String.valueOf(newTableVersion), "key2", "val2"));
 
-    assertThat(meta.formatVersion()).isEqualTo(2);
+    assertThat(meta.formatVersion()).isEqualTo(newTableVersion);
     assertThat(meta.properties())
         .containsEntry("key", "val")
         .containsEntry("key2", "val2")
         .doesNotContainKey(TableProperties.FORMAT_VERSION);
   }
 
-  @Test
-  public void testUpgradeV1MetadataToV2ThroughTableProperty() {
+  @ParameterizedTest
+  @MethodSource("upgradeTableVersionProvider")
+  public void testUpgradeMetadataThroughTableProperty(int baseTableVersion, 
int newTableVersion) {

Review Comment:
   ```suggestion
     public void testUpgradeMetadataThroughTableProperty(int baseFormatVersion, 
int newFormatVersion) {
   ```



-- 
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

Reply via email to