amogh-jahagirdar commented on code in PR #5010:
URL: https://github.com/apache/iceberg/pull/5010#discussion_r895969091


##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -167,8 +177,12 @@ protected void validate(TableMetadata currentMetadata) {
   @Override
   public Snapshot apply() {
     refresh();
-    Long parentSnapshotId = base.currentSnapshot() != null ?
-        base.currentSnapshot().snapshotId() : null;
+    Long parentSnapshotId = null;
+    if(toBranch != null){
+      parentSnapshotId = base.ref(toBranch).snapshotId();
+    } else {
+      parentSnapshotId = base.currentSnapshot() != null ? 
base.currentSnapshot().snapshotId() : null;
+    }

Review Comment:
   We can default assign the parentSnapshotId to what's on line 184 and then 
only override if there's a current branch. I also think the SnapshotProducer 
can maintain the current branch itself as a field, (defaulting to main and then 
getting overrode in the toBranch). 



##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -167,8 +177,12 @@ protected void validate(TableMetadata currentMetadata) {
   @Override
   public Snapshot apply() {
     refresh();
-    Long parentSnapshotId = base.currentSnapshot() != null ?
-        base.currentSnapshot().snapshotId() : null;
+    Long parentSnapshotId = null;
+    if(toBranch != null){
+      parentSnapshotId = base.ref(toBranch).snapshotId();
+    } else {
+      parentSnapshotId = base.currentSnapshot() != null ? 
base.currentSnapshot().snapshotId() : null;
+    }

Review Comment:
   We can default assign the parentSnapshotId to what's on line 184 and then 
only override if there's a current branch. I also think the SnapshotProducer 
can maintain the current branch itself as a field, (defaulting to main and then 
getting overrode in the toBranch).  Let me know what you think!



-- 
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-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to