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/08/01 01:19:50 UTC

[GitHub] [iceberg] amogh-jahagirdar commented on a diff in pull request #4926: Core, API: Performing operations on a snapshot branch ref

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