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


##########
core/src/test/java/org/apache/iceberg/TestFormatVersions.java:
##########
@@ -23,56 +23,95 @@
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 import org.junit.jupiter.api.TestTemplate;
 
 public class TestFormatVersions extends TestBase {
   @Parameters(name = "formatVersion = {0}")
   protected static List<Object> parameters() {
-    return Arrays.asList(1);
+    return Arrays.asList(1, 2);
   }
 
   @TestTemplate
   public void testDefaultFormatVersion() {
-    assertThat(table.ops().current().formatVersion()).isEqualTo(1);
+    assertThat(table.ops().current().formatVersion()).isEqualTo(formatVersion);
   }
 
   @TestTemplate
   public void testFormatVersionUpgrade() {
     TableOperations ops = table.ops();
-    TableMetadata base = ops.current();
-    ops.commit(base, base.upgradeToFormatVersion(2));
+    int newFormatVersion = formatVersion + 1;
+
+    TableMetadata newTableMetadata = 
ops.current().upgradeToFormatVersion(newFormatVersion);
+
+    assertThat(
+            newTableMetadata.changes().stream()
+                .filter(MetadataUpdate.UpgradeFormatVersion.class::isInstance)
+                .map(MetadataUpdate.UpgradeFormatVersion.class::cast)
+                .map(MetadataUpdate.UpgradeFormatVersion::formatVersion))
+        .containsExactly(newFormatVersion);
+
+    ops.commit(ops.current(), newTableMetadata);
 
-    assertThat(ops.current().formatVersion()).isEqualTo(2);
+    assertThat(ops.current().formatVersion()).isEqualTo(newFormatVersion);
+  }
+
+  @TestTemplate
+  public void testFormatVersionUpgradeToLatest() {
+    TableOperations ops = table.ops();
+    int newFormatVersion = TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION;
+
+    TableMetadata newTableMetadata = 
ops.current().upgradeToFormatVersion(newFormatVersion);
+
+    // check that non-incremental updates are syntactic sugar for serial 
updates. E.g. upgrading
+    // from V1 to V3 will register changes in the table metadata for upgrading 
to V2 and V3 in
+    // order (V1->V2->V3)
+    assertThat(

Review Comment:
   Thanks! Reverting the changes in TableMetadata and I'll change the test to 
validate X -> X+1 and X -> latest



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