diff --git a/.palantir/revapi.yml b/.palantir/revapi.yml index 79f1e51ba214..d8894056a0ea 100644 --- a/.palantir/revapi.yml +++ b/.palantir/revapi.yml @@ -27,6 +27,9 @@ acceptedBreaks: - code: "java.method.addedToInterface" new: "method ThisT org.apache.iceberg.SnapshotUpdate::scanManifestsWith(java.util.concurrent.ExecutorService)" justification: "Accept all changes prior to introducing API compatibility checks" + - code: "java.method.addedToInterface" + new: "method ThisT org.apache.iceberg.SnapshotUpdate::toBranch(java.lang.String)" + justification: "Adding toBranch API for supporting committing to a branch" - code: "java.method.addedToInterface" new: "method boolean org.apache.iceberg.expressions.BoundTerm::isEquivalentTo(org.apache.iceberg.expressions.BoundTerm)" justification: "new API method" diff --git a/api/src/main/java/org/apache/iceberg/SnapshotUpdate.java b/api/src/main/java/org/apache/iceberg/SnapshotUpdate.java index 2d94fda8cec3..cc6b02dee474 100644 --- a/api/src/main/java/org/apache/iceberg/SnapshotUpdate.java +++ b/api/src/main/java/org/apache/iceberg/SnapshotUpdate.java @@ -65,5 +65,10 @@ public interface SnapshotUpdate extends PendingUpdate { * * @param branch which is name of SnapshotRef of type branch. */ - ThisT toBranch(String branch); + default ThisT toBranch(String branch) { + throw new UnsupportedOperationException( + String.format( + "Cannot commit to branch %s: %s does not support branch commits", + branch, this.getClass().getName())); + } } diff --git a/core/src/main/java/org/apache/iceberg/SnapshotProducer.java b/core/src/main/java/org/apache/iceberg/SnapshotProducer.java index d8bd80060768..87aa4126ce8f 100644 --- a/core/src/main/java/org/apache/iceberg/SnapshotProducer.java +++ b/core/src/main/java/org/apache/iceberg/SnapshotProducer.java @@ -114,14 +114,6 @@ public ThisT scanManifestsWith(ExecutorService executorService) { return self(); } - @Override - public ThisT toBranch(String branch) { - throw new UnsupportedOperationException( - String.format( - "Cannot commit to branch %s: %s does not support branch commits", - branch, this.getClass().getName())); - } - /** * * A setter for the target branch on which snapshot producer operation should be performed * @@ -178,10 +170,10 @@ public ThisT deleteWith(Consumer deleteCallback) { protected void validate(TableMetadata currentMetadata, Snapshot snapshot) {} /** - * Apply the update's changes to the base table metadata and return the new manifest list. + * Apply the update's changes to the given metadata and snapshot. Return the new manifest list. * * @param metadataToUpdate the base table metadata to apply changes to - * @param snapshot parent snapshot passed to child operations. + * @param snapshot snapshot to apply the changes to * @return a manifest list for the new snapshot. */ protected abstract List apply(TableMetadata metadataToUpdate, Snapshot snapshot);