RussellSpitzer commented on a change in pull request #4141:
URL: https://github.com/apache/iceberg/pull/4141#discussion_r808343419
##########
File path:
spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestExpireSnapshotsProcedure.java
##########
@@ -224,4 +235,62 @@ public void
testConcurrentExpireSnapshotsWithInvalidInput() {
catalogName, tableIdent, -1));
}
+
+ @Test
+ public void testExpireDeleteFiles() throws Exception {
+ sql("CREATE TABLE %s (id bigint NOT NULL, data string) USING iceberg
TBLPROPERTIES" +
+ "('format-version'='2', 'write.delete.mode'='merge-on-read')",
tableName);
+
+ sql("INSERT INTO TABLE %s VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd')",
tableName);
+ sql("DELETE FROM %s WHERE id=1", tableName);
+
+ Table table = validationCatalog.loadTable(tableIdent);
+ table.refresh();
+
+ Assert.assertEquals("Should have 1 delete manifest", 1,
deleteManifests(table).size());
+ Assert.assertEquals("Should have 1 delete file", 1,
deleteFiles(table).size());
+ Path deleteManifestPath = new
Path(deleteManifests(table).iterator().next().path());
+ Path deleteFilePath = new
Path(String.valueOf(deleteFiles(table).iterator().next().path()));
+
+ sql("CALL %s.system.rewrite_data_files(table => '%s', options => map" +
+ "('delete-file-threshold','1', 'use-starting-sequence-number',
'false'))",
+ catalogName, tableIdent);
+
+ table.refresh();
+
+ sql("INSERT INTO TABLE %s VALUES (5, 'e')", tableName); // this txn moves
the file to the DELETED state
+ sql("INSERT INTO TABLE %s VALUES (6, 'f')", tableName); // this txn
removes the file reference
Review comment:
Are we just trying to get 2 Snapshots down here? I think the expire code
would remove the file even after 261 since it only considers live files in the
comparison of reachable files ... or at least it should :)
Nit: "the file" -> "the delete file"
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]