deniskuzZ commented on code in PR #12629:
URL: https://github.com/apache/iceberg/pull/12629#discussion_r2086836242


##########
core/src/main/java/org/apache/iceberg/PartitionStatsHandler.java:
##########
@@ -130,15 +151,28 @@ public static PartitionStatisticsFile 
computeAndWriteStatsFile(Table table) thro
    */
   public static PartitionStatisticsFile computeAndWriteStatsFile(Table table, 
long snapshotId)
       throws IOException {
+    Preconditions.checkArgument(table != null, "Invalid table: null");
+    Preconditions.checkArgument(Partitioning.isPartitioned(table), "Table must 
be partitioned");
     Snapshot snapshot = table.snapshot(snapshotId);
     Preconditions.checkArgument(snapshot != null, "Snapshot not found: %s", 
snapshotId);
 
-    Collection<PartitionStats> stats = computeStats(table, snapshot);
+    StructType partitionType = Partitioning.partitionType(table);
+
+    Collection<PartitionStats> stats;
+    PartitionStatisticsFile statisticsFile = latestStatsFile(table, 
snapshot.snapshotId());
+    if (statisticsFile == null) {
+      LOG.info(
+          "Using full compute as previous statistics file is not present for 
incremental compute.");
+      stats = computeStats(table, snapshot, file -> true, false /* incremental 
*/).values();
+    } else {
+      stats = incrementalComputeAndMerge(table, snapshot, partitionType, 
statisticsFile);

Review Comment:
   maybe `incrementalStatsComputeAndMerge`



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