luoyuxia commented on code in PR #1658:
URL: https://github.com/apache/fluss/pull/1658#discussion_r2332757701
##########
fluss-lake/fluss-lake-iceberg/src/test/java/org/apache/fluss/lake/iceberg/maintenance/IcebergRewriteITCase.java:
##########
@@ -48,42 +68,148 @@ protected static void beforeAll() {
execEnv.enableCheckpointing(1000);
}
+ @Test
+ void testPosDeleteCompaction() throws Exception {
Review Comment:
```suggestion
void testPrimaryKeyTableCompaction() throws Exception {
```
##########
fluss-lake/fluss-lake-iceberg/src/test/java/org/apache/fluss/lake/iceberg/maintenance/IcebergRewriteITCase.java:
##########
@@ -48,42 +68,148 @@ protected static void beforeAll() {
execEnv.enableCheckpointing(1000);
}
+ @Test
+ void testPosDeleteCompaction() throws Exception {
+ JobClient jobClient = buildTieringJob(execEnv);
+ try {
+ TablePath t1 = TablePath.of(DEFAULT_DB, "pk_table_1");
+ long t1Id = createPkTable(t1, 1, true, pkSchema);
+ TableBucket t1Bucket = new TableBucket(t1Id, 0);
+ List<InternalRow> flussRows = new ArrayList<>();
+
+ List<InternalRow> rows = Collections.singletonList(row(1, "v1"));
+ writeIcebergTableRecords(t1, t1Bucket, 1, false, rows);
+ flussRows.addAll(rows);
+
+ rows = Collections.singletonList(row(2, "v1"));
+ writeIcebergTableRecords(t1, t1Bucket, 2, false, rows);
+ flussRows.addAll(rows);
+
+ // add pos-delete
+ rows = Arrays.asList(row(3, "v1"), row(3, "v2"));
+ writeIcebergTableRecords(t1, t1Bucket, 5, false, rows);
+ // one UPDATE_BEFORE and one UPDATE_AFTER
+ checkFileStatusInIcebergTable(t1, 3, true);
+ flussRows.add(rows.get(1));
+
+ // trigger compaction
+ rows = Collections.singletonList(row(4, "v1"));
+ writeIcebergTableRecords(t1, t1Bucket, 6, false, rows);
+ checkFileStatusInIcebergTable(t1, 2, false);
+ flussRows.addAll(rows);
+
+ checkRecords(getIcebergRecords(t1), flussRows);
+ } finally {
+ jobClient.cancel().get();
+ }
+ }
+
+ private void checkRecords(List<Record> actualRows, List<InternalRow>
expectedRows) {
+ // check records size
+ assertThat(actualRows.size()).isEqualTo(expectedRows.size());
+
+ // check records content
+ Iterator<Record> actualIterator =
+ actualRows.stream()
+ .sorted(Comparator.comparingInt((Record r) -> (int)
r.get(0)))
+ .iterator();
+ Iterator<InternalRow> expectedIterator =
+ expectedRows.stream().sorted(Comparator.comparingInt(r ->
r.getInt(0))).iterator();
+ while (actualIterator.hasNext() && expectedIterator.hasNext()) {
+ Record record = actualIterator.next();
+ InternalRow row = expectedIterator.next();
+ assertThat(record.get(0)).isEqualTo(row.getInt(0));
+ assertThat(record.get(1)).isEqualTo(row.getString(1).toString());
+ }
+ assertThat(actualIterator.hasNext()).isFalse();
+ assertThat(expectedIterator.hasNext()).isFalse();
+ }
+
+ @Test
+ void testPosDeleteDuringCompaction() throws Exception {
Review Comment:
nit:
```suggestion
void test testCompactionWithConflict() throws Exception {
```
--
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]