linyanghao commented on code in PR #7218: URL: https://github.com/apache/iceberg/pull/7218#discussion_r1169180646
########## flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/actions/TestRewriteDataFilesAction.java: ########## @@ -386,4 +402,56 @@ public void testRewriteAvoidRepeateCompress() throws IOException { expected.add(SimpleDataUtil.createRecord(2, "b")); SimpleDataUtil.assertTableRecords(icebergTableUnPartitioned, expected); } + + @Test + public void testRewriteNoConflictWithEqualityDeletes() throws IOException { + // Add 2 data files + sql("INSERT INTO %s SELECT 1, 'hello'", TABLE_NAME_WITH_PK); + sql("INSERT INTO %s SELECT 2, 'world'", TABLE_NAME_WITH_PK); + + // Load 2 stale tables to pass to rewrite actions + Table stale1 = + validationCatalog.loadTable(TableIdentifier.of(icebergNamespace, TABLE_NAME_WITH_PK)); + Table stale2 = + validationCatalog.loadTable(TableIdentifier.of(icebergNamespace, TABLE_NAME_WITH_PK)); + + // Add 1 data file and 1 equality-delete file + sql("INSERT INTO %s /*+ OPTIONS('upsert-enabled'='true')*/ SELECT 1, 'hi'", TABLE_NAME_WITH_PK); + + icebergTableWithPk.refresh(); + CloseableIterable<FileScanTask> tasks = icebergTableWithPk.newScan().planFiles(); + List<DataFile> dataFiles = + Lists.newArrayList(CloseableIterable.transform(tasks, FileScanTask::file)); + Set<DeleteFile> deleteFiles = + Lists.newArrayList(CloseableIterable.transform(tasks, FileScanTask::deletes)).stream() + .flatMap(Collection::stream) + .collect(Collectors.toSet()); + Assert.assertEquals("Should have 3 data files before rewrite", 3, dataFiles.size()); + Assert.assertEquals("Should have 1 delete file before rewrite", 1, deleteFiles.size()); + Assert.assertSame( + "The 1 delete file should be an equality-delete file", + Iterables.getOnlyElement(deleteFiles).content(), + FileContent.EQUALITY_DELETES); Review Comment: Added an assertion that compare the sequence number of the current snapshot and stale ones. Did you mean this? -- 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