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: [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]

Reply via email to