rdblue commented on a change in pull request #2358:
URL: https://github.com/apache/iceberg/pull/2358#discussion_r604340026



##########
File path: core/src/main/java/org/apache/iceberg/PartitionsTable.java
##########
@@ -98,21 +105,46 @@ private DataTask task(TableScan scan) {
     return StaticDataTask.Row.of(partition.key, partition.recordCount, 
partition.fileCount);
   }
 
-  private static Iterable<Partition> partitions(Table table, Long snapshotId) {
+  private Iterable<Partition> partitions(StaticTableScan scan) {
+    CloseableIterable<FileScanTask> tasks = planTasks(scan);
+
     PartitionMap partitions = new PartitionMap(table.spec().partitionType());
-    TableScan scan = table.newScan();
+    for (FileScanTask task : tasks) {
+      partitions.get(task.file().partition()).update(task.file());
+    }
+    return partitions.all();
+  }
 
-    if (snapshotId != null) {
-      scan = scan.useSnapshot(snapshotId);
+  @VisibleForTesting
+  CloseableIterable<FileScanTask> planTasks(StaticTableScan scan) {
+    boolean caseSensitive = scan.isCaseSensitive();
+    boolean ignoreResiduals = scan.shouldIgnoreResiduals();
+    long snapshotId = scan.snapshot().snapshotId();
+
+    ManifestEvaluator eval = ManifestEvaluator.forPartitionFilter(
+        Projections.metadata(table.spec(), 
caseSensitive).project(scan.filter()),

Review comment:
       Is the purpose of the "metadata" projection just to rewrite predicates? 
For example, from `partition.x > 3` to `x > 3`?
   
   I'm not sure that I would consider that a projection, but I need to think 
about it a bit more.
   
   We can accomplish the same thing by creating an identity partition spec from 
the partition table's field names to the actual partition names. Or we could 
possibly just rewrite the predicates and remove `partition.`. Those options 
seem a bit simpler conceptually than using projection.




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

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