You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/08/06 13:30:37 UTC

[GitHub] [iceberg] chenjunjiedada commented on a change in pull request #1101: Add sequence number assertions in merge append unit tests

chenjunjiedada commented on a change in pull request #1101:
URL: https://github.com/apache/iceberg/pull/1101#discussion_r466413196



##########
File path: core/src/test/java/org/apache/iceberg/TestMergeAppend.java
##########
@@ -183,31 +183,97 @@ public void testManifestMergeMinCount() throws IOException {
 
     TableMetadata base = readMetadata();
     Assert.assertNull("Should not have a current snapshot", base.currentSnapshot());
+    V2Assert.assertEquals("Last sequence number should be 0", 0, readMetadata().lastSequenceNumber());
+    V1Assert.assertEquals("Table should end with last-sequence-number 0", 0, base.lastSequenceNumber());
 
     ManifestFile manifest = writeManifest(FILE_A);
     ManifestFile manifest2 = writeManifestWithName("FILE_C", FILE_C);
     ManifestFile manifest3 = writeManifestWithName("FILE_D", FILE_D);
+    ManifestFile manifest4 = writeManifestWithName("FILE_B", FILE_B);
     table.newAppend()
         .appendManifest(manifest)
         .appendManifest(manifest2)
         .appendManifest(manifest3)
         .commit();
 
+    Snapshot snap1 = table.currentSnapshot();
+    long commitId1 = snap1.snapshotId();
+    base = readMetadata();
     Assert.assertEquals("Should contain 2 merged manifest for first write",
         2, readMetadata().currentSnapshot().allManifests().size());
+    validateManifest(snap1.allManifests().get(0),
+        seqs(1),
+        ids(commitId1),
+        files(FILE_A));
+    validateManifest(snap1.allManifests().get(1),
+        seqs(1, 1),
+        ids(commitId1, commitId1),
+        files(FILE_C, FILE_D));
+
+    V2Assert.assertEquals("Snapshot sequence number should be 1", 1, snap1.sequenceNumber());
+    V2Assert.assertEquals("Last sequence number should be 1", 1, base.lastSequenceNumber());
+    V1Assert.assertEquals("Table should end with last-sequence-number 0", 0, base.lastSequenceNumber());
 
     table.newAppend()
         .appendManifest(manifest)
         .appendManifest(manifest2)
         .appendManifest(manifest3)
         .commit();
-
+    Snapshot snap2 = table.currentSnapshot();
+    long commitId2 = snap2.snapshotId();
+    base = readMetadata();
     Assert.assertEquals("Should contain 3 merged manifest for second write",
         3, readMetadata().currentSnapshot().allManifests().size());
+    validateManifest(snap2.allManifests().get(0),
+        seqs(2),
+        ids(commitId2),
+        files(FILE_A));
+
+    validateManifest(snap2.allManifests().get(1),
+        seqs(2, 2),
+        ids(commitId2, commitId2),
+        files(FILE_C, FILE_D));
+
+    validateManifestEntries(snap2.allManifests().get(2),
+        ids(commitId1, commitId1, commitId1),
+        files(FILE_A, FILE_C, FILE_D),
+        statuses(Status.EXISTING, Status.EXISTING, Status.EXISTING));
+
+    validateManifest(snap2.allManifests().get(2),
+        seqs(1, 1, 1),
+        ids(commitId1, commitId1, commitId1),
+        files(FILE_A, FILE_C, FILE_D));
+    V2Assert.assertEquals("Snapshot sequence number should be 2", 2, snap2.sequenceNumber());
+    V2Assert.assertEquals("Last sequence number should be 2", 2, base.lastSequenceNumber());
+    V1Assert.assertEquals("Table should end with last-sequence-number 0", 0, base.lastSequenceNumber());
 
     // validate that the metadata summary is correct when using appendManifest
     Assert.assertEquals("Summary metadata should include 3 added files",
         "3", readMetadata().currentSnapshot().summary().get("added-data-files"));
+
+    table.updateProperties()

Review comment:
       It is the removed case in TestSequenceNumberForV2Table.java. Moved it to a new method.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org