amogh-jahagirdar commented on code in PR #13555:
URL: https://github.com/apache/iceberg/pull/13555#discussion_r2212530977


##########
spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteDataFilesAction.java:
##########
@@ -467,76 +470,111 @@ public void 
testDataFilesNotRewrittenWithLowDeleteRatio() throws Exception {
   }
 
   @TestTemplate
-  public void testBinPackWithDeletes() throws IOException {
-    assumeThat(formatVersion).isGreaterThanOrEqualTo(2);
+  public void testBinPackWithDVs() throws IOException {
+    assumeThat(formatVersion).isGreaterThanOrEqualTo(3);
     Table table = createTablePartitioned(4, 2);
     shouldHaveFiles(table, 8);
     table.refresh();
-
+    List<Object[]> initialRecords = currentDataWithLineage();
+    Set<Long> rowIds =
+        initialRecords.stream().map(record -> (Long) 
record[0]).collect(Collectors.toSet());
+    Set<Long> lastUpdatedSequenceNumbers =
+        initialRecords.stream().map(record -> (Long) 
record[1]).collect(Collectors.toSet());
+    assertThat(rowIds)
+        .isEqualTo(LongStream.range(0, 
initialRecords.size()).boxed().collect(Collectors.toSet()));
+    assertThat(lastUpdatedSequenceNumbers).allMatch(sequenceNumber -> 
sequenceNumber.equals(1L));
     List<DataFile> dataFiles = TestHelpers.dataFiles(table);
     int total = (int) 
dataFiles.stream().mapToLong(ContentFile::recordCount).sum();
 
     RowDelta rowDelta = table.newRowDelta();
-    if (formatVersion >= 3) {
-      // delete 1 position for data files 0, 1, 2
-      for (int i = 0; i < 3; i++) {
-        writeDV(table, dataFiles.get(i).partition(), 
dataFiles.get(i).location(), 1)
-            .forEach(rowDelta::addDeletes);
-      }
+    Set<Long> rowIdsBeingRemoved = Sets.newHashSet();
 
-      // delete 2 positions for data files 3, 4
-      for (int i = 3; i < 5; i++) {
-        writeDV(table, dataFiles.get(i).partition(), 
dataFiles.get(i).location(), 2)
-            .forEach(rowDelta::addDeletes);
-      }
-    } else {
-      // add 1 delete file for data files 0, 1, 2
-      for (int i = 0; i < 3; i++) {
-        writePosDeletesToFile(table, dataFiles.get(i), 
1).forEach(rowDelta::addDeletes);
-      }
+    // add 1 DV for data files 0, 1, 2
+    for (int i = 0; i < 3; i++) {
+      writeDV(table, dataFiles.get(i).partition(), 
dataFiles.get(i).location(), 1)
+          .forEach(rowDelta::addDeletes);
+      rowIdsBeingRemoved.add(dataFiles.get(i).firstRowId());
+    }
 
-      // add 2 delete files for data files 3, 4
-      for (int i = 3; i < 5; i++) {
-        writePosDeletesToFile(table, dataFiles.get(i), 
2).forEach(rowDelta::addDeletes);
-      }
+    // delete 2 positions for data files 3, 4
+    for (int i = 3; i < 5; i++) {
+      writeDV(table, dataFiles.get(i).partition(), 
dataFiles.get(i).location(), 2)
+          .forEach(rowDelta::addDeletes);
+      long dataFileFirstRowId = dataFiles.get(i).firstRowId();
+      rowIdsBeingRemoved.add(dataFileFirstRowId);
+      rowIdsBeingRemoved.add(dataFileFirstRowId + 1);
     }
 
     rowDelta.commit();
     table.refresh();

Review Comment:
   I separated the V2 pos delete and V3 DV test cases since the V3 test cases 
will also include lineage assertions



-- 
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

Reply via email to