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


##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -116,6 +117,38 @@ public ThisT scanManifestsWith(ExecutorService 
executorService) {
     return self();
   }
 
+  @Override
+  public ThisT toBranch(String branch) {
+    throw new UnsupportedOperationException("Performing operations on a branch 
is currently not supported");
+  }
+
+  /***
+   * Will be used by snapshot producer operations to create a new ref if an 
invalid branch is passed

Review Comment:
   Can we also update the comment, instead of "invalid branch" I think it 
should be "create a new branch if it does not exist"



##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -116,6 +117,38 @@ public ThisT scanManifestsWith(ExecutorService 
executorService) {
     return self();
   }
 
+  @Override
+  public ThisT toBranch(String branch) {
+    throw new UnsupportedOperationException("Performing operations on a branch 
is currently not supported");
+  }
+
+  /***
+   * Will be used by snapshot producer operations to create a new ref if an 
invalid branch is passed
+   * @param branch ref name on which operation is to performed
+   */
+  protected void createNewRef(String branch) {
+    SnapshotRef branchRef = 
SnapshotRef.branchBuilder(this.current().currentSnapshot().snapshotId()).build();
+    TableMetadata.Builder updatedBuilder = 
TableMetadata.buildFrom(this.current());
+    updatedBuilder.setRef(branch, branchRef);
+    ops.commit(ops.current(), updatedBuilder.build());

Review Comment:
   Yeah if we're creating a new branch, the transaction needs to encapsulate 
the branch creation and the producing of the snapshot.



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