rdblue commented on code in PR #5234: URL: https://github.com/apache/iceberg/pull/5234#discussion_r1083113239
########## core/src/test/java/org/apache/iceberg/TestRowDelta.java: ########## @@ -81,155 +95,171 @@ public void testAddDeleteFile() { @Test public void testValidateDataFilesExistDefaults() { - table.newAppend().appendFile(FILE_A).appendFile(FILE_B).commit(); + SnapshotUpdate rowDelta1 = table.newAppend().appendFile(FILE_A).appendFile(FILE_B); + + commit(table, rowDelta1, branch); // test changes to the table back to the snapshot where FILE_A and FILE_B existed - long validateFromSnapshotId = table.currentSnapshot().snapshotId(); + long validateFromSnapshotId = latestSnapshot(table, branch).snapshotId(); // overwrite FILE_A - table.newOverwrite().deleteFile(FILE_A).addFile(FILE_A2).commit(); + SnapshotUpdate rowDelta2 = table.newOverwrite().deleteFile(FILE_A).addFile(FILE_A2); + + commit(table, rowDelta2, branch); // delete FILE_B - table.newDelete().deleteFile(FILE_B).commit(); + SnapshotUpdate rowDelta3 = table.newDelete().deleteFile(FILE_B); - long deleteSnapshotId = table.currentSnapshot().snapshotId(); + commit(table, rowDelta3, branch); + + long deleteSnapshotId = latestSnapshot(table, branch).snapshotId(); AssertHelpers.assertThrows( "Should fail to add FILE_A_DELETES because FILE_A is missing", ValidationException.class, "Cannot commit, missing data files", () -> - table - .newRowDelta() - .addDeletes(FILE_A_DELETES) - .validateFromSnapshot(validateFromSnapshotId) - .validateDataFilesExist(ImmutableList.of(FILE_A.path())) - .commit()); + commit( + table, + table + .newRowDelta() + .addDeletes(FILE_A_DELETES) + .validateFromSnapshot(validateFromSnapshotId) + .validateDataFilesExist(ImmutableList.of(FILE_A.path())), + branch)); Assert.assertEquals( "Table state should not be modified by failed RowDelta operation", deleteSnapshotId, - table.currentSnapshot().snapshotId()); + latestSnapshot(table, branch).snapshotId()); Assert.assertEquals( "Table should not have any delete manifests", 0, - table.currentSnapshot().deleteManifests(table.io()).size()); + latestSnapshot(table, branch).deleteManifests(table.io()).size()); - table - .newRowDelta() - .addDeletes(FILE_B_DELETES) - .validateDataFilesExist(ImmutableList.of(FILE_B.path())) - .validateFromSnapshot(validateFromSnapshotId) - .commit(); + commit( + table, + table + .newRowDelta() + .addDeletes(FILE_B_DELETES) + .validateDataFilesExist(ImmutableList.of(FILE_B.path())) + .validateFromSnapshot(validateFromSnapshotId), + branch); Assert.assertEquals( "Table should have one new delete manifest", 1, - table.currentSnapshot().deleteManifests(table.io()).size()); - ManifestFile deletes = table.currentSnapshot().deleteManifests(table.io()).get(0); + latestSnapshot(table, branch).deleteManifests(table.io()).size()); + ManifestFile deletes = latestSnapshot(table, branch).deleteManifests(table.io()).get(0); validateDeleteManifest( deletes, dataSeqs(4L), fileSeqs(4L), - ids(table.currentSnapshot().snapshotId()), + ids(latestSnapshot(table, branch).snapshotId()), files(FILE_B_DELETES), statuses(Status.ADDED)); } @Test public void testValidateDataFilesExistOverwrite() { - table.newAppend().appendFile(FILE_A).appendFile(FILE_B).commit(); + commit(table, table.newAppend().appendFile(FILE_A).appendFile(FILE_B), branch); // test changes to the table back to the snapshot where FILE_A and FILE_B existed - long validateFromSnapshotId = table.currentSnapshot().snapshotId(); + long validateFromSnapshotId = latestSnapshot(table, branch).snapshotId(); // overwrite FILE_A - table.newOverwrite().deleteFile(FILE_A).addFile(FILE_A2).commit(); + commit(table, table.newOverwrite().deleteFile(FILE_A).addFile(FILE_A2), branch); - long deleteSnapshotId = table.currentSnapshot().snapshotId(); + long deleteSnapshotId = latestSnapshot(table, branch).snapshotId(); AssertHelpers.assertThrows( "Should fail to add FILE_A_DELETES because FILE_A is missing", ValidationException.class, "Cannot commit, missing data files", () -> - table - .newRowDelta() - .addDeletes(FILE_A_DELETES) - .validateFromSnapshot(validateFromSnapshotId) - .validateDataFilesExist(ImmutableList.of(FILE_A.path())) - .commit()); + commit( + table, + table + .newRowDelta() + .addDeletes(FILE_A_DELETES) + .validateFromSnapshot(validateFromSnapshotId) + .validateDataFilesExist(ImmutableList.of(FILE_A.path())), + branch)); Assert.assertEquals( "Table state should not be modified by failed RowDelta operation", deleteSnapshotId, - table.currentSnapshot().snapshotId()); + latestSnapshot(table, branch).snapshotId()); Assert.assertEquals( "Table should not have any delete manifests", 0, - table.currentSnapshot().deleteManifests(table.io()).size()); + latestSnapshot(table, branch).deleteManifests(table.io()).size()); } @Test public void testValidateDataFilesExistReplacePartitions() { - table.newAppend().appendFile(FILE_A).appendFile(FILE_B).commit(); + commit(table, table.newAppend().appendFile(FILE_A).appendFile(FILE_B), branch); // test changes to the table back to the snapshot where FILE_A and FILE_B existed - long validateFromSnapshotId = table.currentSnapshot().snapshotId(); + long validateFromSnapshotId = latestSnapshot(table, branch).snapshotId(); // overwrite FILE_A's partition - table.newReplacePartitions().addFile(FILE_A2).commit(); + commit(table, table.newReplacePartitions().addFile(FILE_A2), branch); - long deleteSnapshotId = table.currentSnapshot().snapshotId(); + long deleteSnapshotId = latestSnapshot(table, branch).snapshotId(); AssertHelpers.assertThrows( "Should fail to add FILE_A_DELETES because FILE_A is missing", ValidationException.class, "Cannot commit, missing data files", () -> - table - .newRowDelta() - .addDeletes(FILE_A_DELETES) - .validateFromSnapshot(validateFromSnapshotId) - .validateDataFilesExist(ImmutableList.of(FILE_A.path())) - .commit()); + commit( + table, + table + .newRowDelta() + .addDeletes(FILE_A_DELETES) + .validateFromSnapshot(validateFromSnapshotId) + .validateDataFilesExist(ImmutableList.of(FILE_A.path())), + branch)); Assert.assertEquals( "Table state should not be modified by failed RowDelta operation", deleteSnapshotId, - table.currentSnapshot().snapshotId()); + latestSnapshot(table, branch).snapshotId()); Assert.assertEquals( "Table should not have any delete manifests", 0, - table.currentSnapshot().deleteManifests(table.io()).size()); + latestSnapshot(table, branch).deleteManifests(table.io()).size()); } - @Test + // @Test Review Comment: @amogh-jahagirdar, why is this test disabled? -- 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