deniskuzZ commented on code in PR #12629:
URL: https://github.com/apache/iceberg/pull/12629#discussion_r2013805250
##########
data/src/main/java/org/apache/iceberg/data/PartitionStatsHandler.java:
##########
@@ -149,6 +162,92 @@ public static PartitionStatisticsFile
computeAndWriteStatsFile(Table table, long
table, snapshot.snapshotId(), schema(partitionType), sortedStats);
}
+ /**
+ * Incrementally computes the stats after the snapshot that has partition
stats file till the
+ * given snapshot and writes the combined result into a {@link
PartitionStatisticsFile} after
+ * merging the stats.
+ *
+ * @param table The {@link Table} for which the partition statistics is
computed.
+ * @param snapshotId snapshot for which partition statistics are computed.
+ * @return {@link PartitionStatisticsFile} for the given snapshot, or null
if no statistics are
+ * present.
+ */
+ public static PartitionStatisticsFile computeAndWriteStatsFileIncremental(
+ Table table, long snapshotId) throws IOException {
+ Preconditions.checkArgument(table != null, "Table cannot be null");
+ Snapshot snapshot = table.snapshot(snapshotId);
+ Preconditions.checkArgument(snapshot != null, "Snapshot not found: %s",
snapshotId);
+
+ StructType partitionType = Partitioning.partitionType(table);
+ Schema statsFileSchema = schema(partitionType);
+ PartitionStatisticsFile statisticsFile = latestStatsFile(table,
snapshotId);
Review Comment:
I think that should be extracted to `collectStats`. `computeAndWriteStats`
should call `collectStats` and write it to FS
##########
data/src/main/java/org/apache/iceberg/data/PartitionStatsHandler.java:
##########
@@ -149,6 +162,92 @@ public static PartitionStatisticsFile
computeAndWriteStatsFile(Table table, long
table, snapshot.snapshotId(), schema(partitionType), sortedStats);
}
+ /**
+ * Incrementally computes the stats after the snapshot that has partition
stats file till the
+ * given snapshot and writes the combined result into a {@link
PartitionStatisticsFile} after
+ * merging the stats.
+ *
+ * @param table The {@link Table} for which the partition statistics is
computed.
+ * @param snapshotId snapshot for which partition statistics are computed.
+ * @return {@link PartitionStatisticsFile} for the given snapshot, or null
if no statistics are
+ * present.
+ */
+ public static PartitionStatisticsFile computeAndWriteStatsFileIncremental(
+ Table table, long snapshotId) throws IOException {
+ Preconditions.checkArgument(table != null, "Table cannot be null");
+ Snapshot snapshot = table.snapshot(snapshotId);
+ Preconditions.checkArgument(snapshot != null, "Snapshot not found: %s",
snapshotId);
+
+ StructType partitionType = Partitioning.partitionType(table);
+ Schema statsFileSchema = schema(partitionType);
+ PartitionStatisticsFile statisticsFile = latestStatsFile(table,
snapshotId);
Review Comment:
I think that should be extracted to `collectStats`.
`computeAndWriteStats` should call `collectStats` and write it to FS
--
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]