amogh-jahagirdar commented on code in PR #13614: URL: https://github.com/apache/iceberg/pull/13614#discussion_r2226802628
########## core/src/main/java/org/apache/iceberg/RemoveSnapshots.java: ########## @@ -390,4 +386,43 @@ private void cleanExpiredSnapshots() { cleanupStrategy.cleanFiles(base, current); } + + private void validateCleanupCanBeIncremental(TableMetadata current) { + if (specifiedSnapshotId) { + throw new UnsupportedOperationException( + "Cannot clean files incrementally when snapshot IDs are specified"); + } + + if (current.refs().size() > 1) { + throw new UnsupportedOperationException( + "Cannot incrementally clean files for tables with more than 1 ref"); + } + + if (!allRemovedSnapshotsAreInMainAncestry(current)) { + throw new UnsupportedOperationException( + "Cannot incrementally clean files when snapshots outside of main ancestry have been removed"); + } + } + + private boolean allRemovedSnapshotsAreInMainAncestry(TableMetadata current) { + Set<Long> snapshotsBeforeExpiration = + base.snapshots().stream().map(Snapshot::snapshotId).collect(Collectors.toSet()); Review Comment: Don't need the extra set here, can just iterate over it -- 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