rdblue commented on code in PR #8147:
URL: https://github.com/apache/iceberg/pull/8147#discussion_r1274225077
##########
core/src/main/java/org/apache/iceberg/UpdateRequirement.java:
##########
@@ -199,4 +220,56 @@ public void validate(TableMetadata base) {
}
}
}
+
+ class AssertLastAssignedViewVersionId implements UpdateRequirement {
+ private final int versionId;
+
+ public AssertLastAssignedViewVersionId(int versionId) {
+ this.versionId = versionId;
+ }
+
+ public int versionId() {
+ return versionId;
+ }
+
+ @Override
+ public void validate(TableMetadata base) {
+ // noop
+ }
+
+ @Override
+ public void validate(ViewMetadata base) {
+ if (versionId != base.currentVersionId()) {
+ throw new CommitFailedException(
+ "Requirement failed: last assigned view version id changed:
expected id %s != %s",
+ versionId, base.currentVersionId());
+ }
+ }
+ }
+
+ class AssertCurrentViewVersionID implements UpdateRequirement {
Review Comment:
Do we need this?
I don't think we need it because adding a new view version will assign a new
ID (see the comment above) and setting the current version is an idempotent
operation. We have a similar assertion, `AssertRefSnapshotId`, for snapshots,
but that is because snapshots are based on one another. Here, view versions are
completely independent and so replacing is an idempotent operation.
We _could_ add this if we wanted to make it possible to perform either an
idempotent replace OR fail. But I don't really see a good argument for the
failure case. Open to suggestion here though.
--
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]