timothyw553 commented on code in PR #19152:
URL: https://github.com/apache/iceberg/pull/19152#discussion_r4728611846


##########
core/src/main/java/org/apache/iceberg/BaseTableScan.java:
##########
@@ -45,6 +45,10 @@ public CloseableIterable<CombinedScanTask> planTasks() {
     CloseableIterable<FileScanTask> splitFiles =
         TableScanUtil.splitFiles(fileScanTasks, targetSplitSize());
     return TableScanUtil.planTasks(
-        splitFiles, targetSplitSize(), splitLookback(), splitOpenFileCost());
+        splitFiles,
+        targetSplitSize(),
+        splitLookback(),
+        splitOpenFileCost(),
+        shareEqualityDeletes());

Review Comment:
   so iiuc this only wires `shareEqualityDeletes()` into `BaseTableScan`, while 
`BaseDistributedDataScan` (and spark callers of `TableScanUtil.planTaskGroups`) 
still call the old overload and get `false`. should we forward 
`shareEqualityDeletes()` in `BaseDistributedDataScan#planTasks` too, or 
document if limited support is intentional?



##########
core/src/test/java/org/apache/iceberg/util/TestTableScanUtil.java:
##########
@@ -132,6 +135,49 @@ public void testPlanTaskWithDeleteFiles() {
     }
   }
 
+  @ParameterizedTest(name = "shareEqualityDeletes = {0}")
+  @ValueSource(booleans = {false, true})
+  public void testPlanSharedEqualityDeletes(boolean shareEqualityDeletes) {
+    DeleteFile sharedDelete =
+        FileMetadata.deleteFileBuilder(SPEC1)
+            .ofEqualityDeletes()
+            .withPath("/path/to/shared-delete.parquet")
+            .withFileSizeInBytes(10L)
+            .withRecordCount(2)
+            .build();
+    DataFile data1 =
+        DataFiles.builder(SPEC1)
+            .withPath("/path/to/data-1.parquet")
+            .withFileSizeInBytes(250L)
+            .withRecordCount(1)
+            .build();
+    DataFile data2 =
+        DataFiles.builder(SPEC1)
+            .withPath("/path/to/data-2.parquet")
+            .withFileSizeInBytes(250L)
+            .withRecordCount(1)
+            .build();
+
+    List<FileScanTask> tasks =
+        ImmutableList.of(
+            new MockFileScanTask(data1, new DeleteFile[] {sharedDelete}, 
TEST_SCHEMA, SPEC1),
+            new MockFileScanTask(data2, new DeleteFile[] {sharedDelete}, 
TEST_SCHEMA, SPEC1));
+
+    // counted per data file: 260 B + 260 B = 520 B > 512 B -> 2 bins
+    // counted once per bin:  260 B + 250 B = 510 B < 512 B -> 1 bin
+    int bins = shareEqualityDeletes ? 1 : 2;
+    assertThat(
+            TableScanUtil.planTasks(
+                CloseableIterable.withNoopClose(tasks), 512L, 1, 0L, 
shareEqualityDeletes))

Review Comment:
   since everything fits in one bin here, this doesn't guard against state 
leaking across bins or `tentativeWeight` mutating state when a bin rejects an 
item. could we add multi-bin cases with `lookback = 2` (e.g. `300+D, 300+D, 
200` -> 3 bins, and `350, 300+D, 100+D` -> `[350] [300+D, 100+D]`) and assert 
group membership rather than just bin count?



##########
core/src/test/java/org/apache/iceberg/TestSplitPlanning.java:
##########
@@ -165,6 +165,28 @@ public void testSplitPlanningWithOverridenOpenCostSize() {
     assertThat(scan.planTasks()).hasSize(4);
   }
 
+  @TestTemplate
+  public void testSplitPlanningWithSharedEqualityDeletes() {
+    appendFiles(newFiles(2, 56 * 1024 * 1024));
+    DeleteFile eqDeletes =
+        FileMetadata.deleteFileBuilder(PartitionSpec.unpartitioned())
+            .ofEqualityDeletes(1)
+            
.withPath(FileFormat.PARQUET.addExtension(UUID.randomUUID().toString()))
+            .withFileSizeInBytes(12 * 1024 * 1024)
+            .withRecordCount(2)
+            .build();
+    appendDeleteFiles(List.of(eqDeletes));
+
+    // the equality delete applies to both data files, so each task weighs 
56MB + 12MB = 68MB
+    // and 2 tasks exceed the 128MB split size
+    assertThat(table.newScan().planTasks()).hasSize(2);

Review Comment:
   we document in `TableProperties` that this is ignored as a table property, 
but nothing here checks that. could we add that check before enabling the scan 
option?
   
   ```diff
        assertThat(table.newScan().planTasks()).hasSize(2);
   +
   +    table
   +        .updateProperties()
   +        .set(TableProperties.SPLIT_SHARE_EQUALITY_DELETES_ENABLED, "true")
   +        .commit();
   +    assertThat(table.newScan().planTasks()).hasSize(2);
   ```



##########
core/src/test/java/org/apache/iceberg/util/TestTableScanUtil.java:
##########
@@ -132,6 +135,49 @@ public void testPlanTaskWithDeleteFiles() {
     }
   }
 
+  @ParameterizedTest(name = "shareEqualityDeletes = {0}")
+  @ValueSource(booleans = {false, true})
+  public void testPlanSharedEqualityDeletes(boolean shareEqualityDeletes) {
+    DeleteFile sharedDelete =
+        FileMetadata.deleteFileBuilder(SPEC1)
+            .ofEqualityDeletes()

Review Comment:
   this only tests equality deletes with `openFileCost = 0`, so it wouldn't 
catch discounting position deletes or still charging `openFileCost` for an 
already-counted equality delete. could we add a shared position-delete case 
(still 2 bins) and a non-zero `openFileCost` case where sharing avoids the 
extra open cost?



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

Reply via email to