amogh-jahagirdar commented on a change in pull request #4071:
URL: https://github.com/apache/iceberg/pull/4071#discussion_r835792009
##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -1007,6 +1007,33 @@ public Builder setBranchSnapshot(long snapshotId, String
branch) {
return this;
}
+ public Builder setTag(String tag, SnapshotRef ref) {
+ SnapshotRef existingRef = refs.get(tag);
+ if (existingRef != null && existingRef.equals(ref)) {
+ return this;
+ }
+ long snapshotId = ref.snapshotId();
+ Snapshot snapshot = snapshotsById.get(snapshotId);
+ ValidationException.check(snapshot != null, "Cannot set %s to unknown
snapshot: %s", tag, snapshotId);
+ ValidationException.check(ref.isTag(), "Cannot create tag: %s is a
branch", tag);
+ refs.put(tag, ref);
+ return this;
+ }
+
+ public Builder setBranch(String branch, SnapshotRef ref) {
+ SnapshotRef existingRef = refs.get(branch);
+ if (existingRef != null && existingRef.equals(ref)) {
+ return this;
+ }
+ long snapshotId = ref.snapshotId();
+ Snapshot snapshot = snapshotsById.get(snapshotId);
+ ValidationException.check(snapshot != null, "Cannot set %s to unknown
snapshot: %s", branch, snapshotId);
+ ValidationException.check(ref.isBranch(), "Cannot create branch: %s is a
tag", branch);
+ refs.put(branch, ref);
+ return this;
Review comment:
When writing tests, and debugging realized that I need to emit a
MetadataUpdate here. Will do that on next revision
--
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]