szehon-ho commented on code in PR #6365:
URL: https://github.com/apache/iceberg/pull/6365#discussion_r1085823469


##########
core/src/test/java/org/apache/iceberg/TestMetadataTableScans.java:
##########
@@ -1040,4 +1047,195 @@ public void testAllManifestsTableSnapshotNot() {
         expectedManifestListPaths(table.snapshots(), 1L, 3L, 4L),
         actualManifestListPaths(manifestsTableScan));
   }
+
+  @Test
+  public void testPositionDeletesWithFilter() {
+    Assume.assumeTrue("Position deletes supported only for v2 tables", 
formatVersion == 2);
+    preparePartitionedTable();
+
+    PositionDeletesTable positionDeletesTable = new 
PositionDeletesTable(table);
+
+    Expression expression =
+        Expressions.and(
+            Expressions.equal("partition.data_bucket", 1), 
Expressions.greaterThan("pos", 0));
+    BatchScan scan = positionDeletesTable.newBatchScan().filter(expression);
+    
assertThat(scan).isExactlyInstanceOf(PositionDeletesTable.PositionDeletesBatchScan.class);
+
+    List<ScanTask> tasks = Lists.newArrayList(scan.planFiles());
+
+    Assert.assertEquals(
+        "Expected to scan one delete manifest",
+        1,
+        ((PositionDeletesTable.PositionDeletesBatchScan) scan)
+            .scanMetrics()
+            .scannedDeleteManifests()
+            .value());
+    Assert.assertEquals(
+        "Expected to skip three delete manifests",
+        3,
+        ((PositionDeletesTable.PositionDeletesBatchScan) scan)
+            .scanMetrics()
+            .skippedDeleteManifests()
+            .value());
+
+    assertThat(tasks).hasSize(1);
+
+    ScanTask task = tasks.get(0);
+    assertThat(task).isInstanceOf(PositionDeletesScanTask.class);
+
+    Types.StructType partitionType = Partitioning.partitionType(table);
+    PositionDeletesScanTask posDeleteTask = (PositionDeletesScanTask) task;
+
+    Assert.assertEquals(
+        "Expected correct partition on task",
+        1,
+        (int) posDeleteTask.file().partition().get(0, Integer.class));
+    Assert.assertEquals(
+        "Expected correct partition on constant column",
+        1,
+        (int)
+            ((StructLike)
+                    constantsMap(posDeleteTask, partitionType)
+                        .get(MetadataColumns.PARTITION_COLUMN_ID))
+                .get(0, Integer.class));
+
+    Assert.assertEquals(
+        "Expected correct partition spec id on task", 0, 
posDeleteTask.file().specId());
+    Assert.assertEquals(
+        "Expected correct partition spec id on constant column",
+        0,
+        (constantsMap(posDeleteTask, 
partitionType).get(MetadataColumns.SPEC_ID.fieldId())));
+
+    Assert.assertEquals(
+        "Expected correct delete file on task", FILE_B_DELETES.path(), 
posDeleteTask.file().path());
+    Assert.assertEquals(
+        "Expected correct delete file on constant column",
+        FILE_B_DELETES.path(),
+        (constantsMap(posDeleteTask, 
partitionType).get(MetadataColumns.FILE_PATH.fieldId())));

Review Comment:
   Thanks, removed



##########
core/src/test/java/org/apache/iceberg/TestMetadataTableScans.java:
##########
@@ -1040,4 +1047,195 @@ public void testAllManifestsTableSnapshotNot() {
         expectedManifestListPaths(table.snapshots(), 1L, 3L, 4L),
         actualManifestListPaths(manifestsTableScan));
   }
+
+  @Test
+  public void testPositionDeletesWithFilter() {
+    Assume.assumeTrue("Position deletes supported only for v2 tables", 
formatVersion == 2);
+    preparePartitionedTable();
+
+    PositionDeletesTable positionDeletesTable = new 
PositionDeletesTable(table);
+
+    Expression expression =
+        Expressions.and(
+            Expressions.equal("partition.data_bucket", 1), 
Expressions.greaterThan("pos", 0));
+    BatchScan scan = positionDeletesTable.newBatchScan().filter(expression);
+    
assertThat(scan).isExactlyInstanceOf(PositionDeletesTable.PositionDeletesBatchScan.class);
+
+    List<ScanTask> tasks = Lists.newArrayList(scan.planFiles());
+
+    Assert.assertEquals(
+        "Expected to scan one delete manifest",
+        1,
+        ((PositionDeletesTable.PositionDeletesBatchScan) scan)
+            .scanMetrics()
+            .scannedDeleteManifests()
+            .value());
+    Assert.assertEquals(
+        "Expected to skip three delete manifests",
+        3,
+        ((PositionDeletesTable.PositionDeletesBatchScan) scan)
+            .scanMetrics()
+            .skippedDeleteManifests()
+            .value());
+
+    assertThat(tasks).hasSize(1);
+
+    ScanTask task = tasks.get(0);
+    assertThat(task).isInstanceOf(PositionDeletesScanTask.class);
+
+    Types.StructType partitionType = Partitioning.partitionType(table);
+    PositionDeletesScanTask posDeleteTask = (PositionDeletesScanTask) task;
+
+    Assert.assertEquals(
+        "Expected correct partition on task",
+        1,
+        (int) posDeleteTask.file().partition().get(0, Integer.class));
+    Assert.assertEquals(
+        "Expected correct partition on constant column",
+        1,
+        (int)
+            ((StructLike)

Review Comment:
   Done



##########
core/src/test/java/org/apache/iceberg/TestMetadataTableScans.java:
##########
@@ -1040,4 +1047,195 @@ public void testAllManifestsTableSnapshotNot() {
         expectedManifestListPaths(table.snapshots(), 1L, 3L, 4L),
         actualManifestListPaths(manifestsTableScan));
   }
+
+  @Test
+  public void testPositionDeletesWithFilter() {
+    Assume.assumeTrue("Position deletes supported only for v2 tables", 
formatVersion == 2);
+    preparePartitionedTable();
+
+    PositionDeletesTable positionDeletesTable = new 
PositionDeletesTable(table);
+
+    Expression expression =
+        Expressions.and(
+            Expressions.equal("partition.data_bucket", 1), 
Expressions.greaterThan("pos", 0));
+    BatchScan scan = positionDeletesTable.newBatchScan().filter(expression);
+    
assertThat(scan).isExactlyInstanceOf(PositionDeletesTable.PositionDeletesBatchScan.class);
+
+    List<ScanTask> tasks = Lists.newArrayList(scan.planFiles());
+
+    Assert.assertEquals(
+        "Expected to scan one delete manifest",
+        1,
+        ((PositionDeletesTable.PositionDeletesBatchScan) scan)
+            .scanMetrics()
+            .scannedDeleteManifests()
+            .value());
+    Assert.assertEquals(
+        "Expected to skip three delete manifests",
+        3,
+        ((PositionDeletesTable.PositionDeletesBatchScan) scan)

Review Comment:
   Done



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