rdblue commented on code in PR #10962: URL: https://github.com/apache/iceberg/pull/10962#discussion_r1859257408
########## core/src/test/java/org/apache/iceberg/TestRewriteFiles.java: ########## @@ -384,6 +386,116 @@ public void testRewriteDataAndAssignOldSequenceNumber() { assertThat(listManifestFiles()).hasSize(4); } + @TestTemplate + public void testRewriteDataAndAssignOldSequenceNumbersShouldNotDropDeleteFiles() { + assumeThat(formatVersion) + .as("Sequence number is only supported in iceberg format v2 or later") + .isGreaterThan(1); + assertThat(listManifestFiles()).isEmpty(); + + commit(table, table.newRowDelta().addRows(FILE_A).addDeletes(FILE_A2_DELETES), branch); + + long firstRewriteSequenceNumber = latestSnapshot(table, branch).sequenceNumber(); + + commit( + table, + table.newRowDelta().addRows(FILE_B).addRows(FILE_B).addDeletes(FILE_B2_DELETES), + branch); + commit( + table, + table.newRowDelta().addRows(FILE_B).addRows(FILE_C).addDeletes(FILE_C2_DELETES), + branch); + + long secondRewriteSequenceNumber = latestSnapshot(table, branch).sequenceNumber(); + + commit( + table, + table + .newRewrite() + .addFile(FILE_D) + .deleteFile(FILE_B) + .deleteFile(FILE_C) + .dataSequenceNumber(secondRewriteSequenceNumber), + branch); + + TableMetadata base = readMetadata(); + Snapshot baseSnap = latestSnapshot(base, branch); + long baseSnapshotId = baseSnap.snapshotId(); + + Comparator<ManifestFile> sequenceNumberOrdering = Review Comment: You can use `Comparator.comparingLong(ManifestFile::sequenceNumber)` -- 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