You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/03/08 17:24:08 UTC
[GitHub] [iceberg] rdblue commented on a change in pull request #4260: Core: Implement table refs in TableMetadataParser
rdblue commented on a change in pull request #4260:
URL: https://github.com/apache/iceberg/pull/4260#discussion_r821896341
##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -720,15 +728,24 @@ private static SortOrder freshSortOrder(int orderId, Schema schema, SortOrder so
return builder.build();
}
- private Map<String, SnapshotRef> validateRefs(Map<String, SnapshotRef> inputRefs) {
- for (Map.Entry<String, SnapshotRef> refEntry : inputRefs.entrySet()) {
- String refName = refEntry.getKey();
- SnapshotRef ref = refEntry.getValue();
- if (!(ref.snapshotId() == -1 && refName.equals(SnapshotRef.MAIN_BRANCH))) {
- Preconditions.checkArgument(snapshotsById.containsKey(ref.snapshotId()),
- "Snapshot reference %s does not exist in the existing snapshots list", ref);
- }
+ private static Map<String, SnapshotRef> validateRefs(Long currentSnapshotId,
+ Map<String, SnapshotRef> inputRefs,
+ Map<Long, Snapshot> snapshotsById) {
+ for (SnapshotRef ref : inputRefs.values()) {
+ Preconditions.checkArgument(snapshotsById.containsKey(ref.snapshotId()),
+ "Snapshot for reference %s does not exist in the existing snapshots list", ref);
}
+
+ SnapshotRef main = inputRefs.get(SnapshotRef.MAIN_BRANCH);
+ if (currentSnapshotId != -1) {
+ Preconditions.checkArgument(main == null || currentSnapshotId == main.snapshotId(),
+ "Current snapshot ID does not match main branch (%s != %s)",
Review comment:
I strongly prefer keeping the error message itself readable and adding context after. While it is more clear which ID is which in your version, I think it makes the actual problem harder to read because there are longs embedded in the text.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org