szehon-ho commented on code in PR #16753:
URL: https://github.com/apache/iceberg/pull/16753#discussion_r3400462789
##########
core/src/main/java/org/apache/iceberg/TableMetadata.java:
##########
@@ -1327,6 +1327,11 @@ public Builder setRef(String name, SnapshotRef ref) {
Snapshot snapshot = snapshotsById.get(snapshotId);
ValidationException.check(
snapshot != null, "Cannot set %s to unknown snapshot: %s", name,
snapshotId);
+ ValidationException.check(
+ !SnapshotRef.MAIN_BRANCH.equals(name) || ref.isBranch(),
+ "Cannot set %s to a tag: %s must be a branch",
+ SnapshotRef.MAIN_BRANCH,
+ SnapshotRef.MAIN_BRANCH);
Review Comment:
Minor: the message repeats `main` twice (it expands to `Cannot set main to a
tag: main must be a branch`). Could drop the second arg to read a bit cleaner,
while still making clear that `main` *can* be set, just as a branch:
```suggestion
"Cannot set %s to a tag, it must be a branch",
SnapshotRef.MAIN_BRANCH);
```
Non-blocking, and it keeps the same `Cannot set %s to ...` shape as the
sibling unknown-snapshot check just above.
--
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]