ayushtkn commented on code in PR #4627:
URL: https://github.com/apache/hive/pull/4627#discussion_r1304109519


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergTableUtil.java:
##########
@@ -242,4 +242,17 @@ public static void setCurrentSnapshot(Table table, Long 
value) {
     manageSnapshots.setCurrentSnapshot(value);
     manageSnapshots.commit();
   }
+
+  /**
+   * Fast forwards a branch to another.
+   * @param table the iceberg table
+   * @param sourceBranch the source branch
+   * @param targetBranch the target branch
+   */
+  public static void fastForwardBranch(Table table, String sourceBranch, 
String targetBranch) {
+    ManageSnapshots manageSnapshots = table.manageSnapshots();
+    LOG.debug("Fast Forwarding the iceberg table {} branch {} to {}", 
table.name(), sourceBranch, targetBranch);
+    manageSnapshots.fastForwardBranch(sourceBranch, targetBranch);

Review Comment:
   yes, it will throw exception, I will add a -ve test for this case



##########
iceberg/iceberg-handler/src/test/queries/positive/fastforward_iceberg_branch.q:
##########
@@ -0,0 +1,23 @@
+-- SORT_QUERY_RESULTS
+set hive.explain.user=false;
+set hive.fetch.task.conversion=more;
+
+create external table ice01(a int, b string, c int) stored by iceberg stored 
as orc tblproperties ('format-version'='2');
+
+insert into ice01 values (1, 'one', 50), (2, 'two', 51), (111, 'one', 55);
+
+select * from ice01;
+
+-- create a branch named test1
+alter table ice01 create branch test1;
+
+select * from default.ice01.branch_test1;
+
+-- insert into main branch
+insert into ice01 values (10, 'ten', 53), (11, 'eleven', 52), (12, 'twelve', 
56);
+select * from ice01;
+
+-- fastforward the branch
+explain alter table ice01 execute fastforward 'test1' to 'main';
+alter table ice01 execute fastforward 'test1' to 'main';

Review Comment:
   will add one



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