deniskuzZ commented on code in PR #5957: URL: https://github.com/apache/hive/pull/5957#discussion_r2207114763
########## iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/compaction/IcebergTableOptimizer.java: ########## @@ -165,4 +168,73 @@ private void addCompactionTargetIfEligible(Table table, org.apache.iceberg.Table ci.type = compactionEvaluator.determineCompactionType(); compactions.add(ci); } + + /** + * Finds all unique non-compaction-modified partitions (with added or deleted files) between a given past + * snapshot ID and the table's current (latest) snapshot. + * @param hiveTable The {@link org.apache.hadoop.hive.ql.metadata.Table} instance to inspect. + * @param pastSnapshotId The ID of the older snapshot (exclusive). + * @param latestSpecOnly when True, returns partitions with the current spec only; + * False - older specs only; + * Null - any spec + * @return A List of {@link org.apache.hadoop.hive.ql.metadata.Partition} representing the unique modified + * partition names. + * @throws IllegalArgumentException if snapshot IDs are invalid or out of order, or if the table has no current + * snapshot. + */ + private List<Partition> findModifiedPartitions(org.apache.hadoop.hive.ql.metadata.Table hiveTable, + org.apache.iceberg.Table icebergTable, Long pastSnapshotId, Boolean latestSpecOnly) { + Snapshot currentSnapshot = icebergTable.currentSnapshot(); + if (currentSnapshot == null) { + throw new IllegalArgumentException(String.format("Table %s has no current snapshot. Cannot determine range.", + icebergTable.name())); + } + Snapshot pastSnapshot = pastSnapshotId != null ? icebergTable.snapshot(pastSnapshotId) : null; + + List<Snapshot> relevantSnapshots = StreamSupport.stream(icebergTable.snapshots().spliterator(), false) Review Comment: can we extract this and reuse in hasNewCommits? -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org