singhpk234 commented on code in PR #16176:
URL: https://github.com/apache/iceberg/pull/16176#discussion_r3175913919


##########
spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkScanBuilder.java:
##########
@@ -186,6 +196,213 @@ public boolean pushAggregation(Aggregation aggregation) {
     return true;
   }
 
+  /**
+   * Push down aggregation with GROUP BY on identity partition columns. When 
all GROUP BY columns
+   * are identity partition fields, aggregates can be computed from file 
metadata grouped by
+   * partition values, avoiding reading any data files.
+   */
+  private boolean pushGroupByAggregation(
+      Aggregation aggregation, List<BoundAggregate<?, ?>> boundAggregates) {
+    PartitionSpec spec = table().spec();
+    Schema tableSchema = table().schema();
+
+    List<Integer> groupByPositions = Lists.newArrayList();
+    List<Types.NestedField> groupByFields = Lists.newArrayList();
+    if (!resolveGroupByPartitions(
+        aggregation, spec, tableSchema, groupByPositions, groupByFields)) {
+      return false;
+    }
+
+    Map<List<Object>, AggregateEvaluator> evaluatorsByPartition =
+        groupFilesByPartition(spec, groupByPositions, boundAggregates);

Review Comment:
   i am not confident this is correct, plus we are just checking the recent 
partitioning, a table could comprise of lot of different partition spec files 
which evolved across snapshots



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