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/02/16 00:42:59 UTC

[GitHub] [iceberg] wypoon commented on a change in pull request #4135: Core: Call the replaceCurrentSnapshot with snapshotId for rollback operations

wypoon commented on a change in pull request #4135:
URL: https://github.com/apache/iceberg/pull/4135#discussion_r807437913



##########
File path: core/src/main/java/org/apache/iceberg/SnapshotProducer.java
##########
@@ -283,7 +283,10 @@ public void commit() {
             Snapshot newSnapshot = apply();
             newSnapshotId.set(newSnapshot.snapshotId());
             TableMetadata updated;
-            if (stageOnly) {
+            if (base.snapshot(newSnapshot.snapshotId()) != null) {
+              // this is a rollback operation
+              updated = base.replaceCurrentSnapshot(newSnapshot.snapshotId());
+            } else if (stageOnly) {

Review comment:
       @rdblue, would the following be acceptable? (from line 285)
   ```
               TableMetadata.Builder update = TableMetadata.buildFrom(base);
               if (base.snapshot(newSnapshot.snapshotId()) != null) {
                 // this is a rollback or cherrypick operation
                 update.setCurrentSnapshot(newSnapshot.snapshotId());
                 } else if (stageOnly) {
                 update.addSnapshot(newSnapshot);
               } else {
                 update.setCurrentSnapshot(newSnapshot);
               }
   
               TableMetadata updated = update.build();
               if (updated.changes().isEmpty()) {
                 // do not commit if the metadata has not changed. for example, this may happen when setting the current
                 // snapshot to an ID that is already current. note that this check uses identity.
                 return;
               }
   ```
   I know the point of #4089 is to replace `setCurrentSnapshot` with `setBranchSnapshot`, but in 0.13.x, we don't support branching yet, and the commits #4089 builds on are not present.




-- 
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