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


##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestBranchDDL.java:
##########
@@ -89,6 +91,13 @@ public void testCreateBranch() throws NoSuchTableException {
         () -> sql("ALTER TABLE %s CREATE BRANCH %s", tableName, branchName));
   }
 
+  @Test
+  public void testCreateBranchOnEmptyTable() {
+    Assertions.assertThatThrownBy(() -> sql("ALTER TABLE %s CREATE BRANCH %s", 
tableName, "b1"))
+        .isInstanceOf(ValidationException.class)
+        .hasMessageContaining("Cannot set b1 to unknown snapshot");

Review Comment:
   Seems like we're relying on the throw from here? 
https://github.com/apache/iceberg/blob/master/core/src/main/java/org/apache/iceberg/TableMetadata.java#L1170
   
   I'm not sure that's what we want to do, that's supposed to be for assigning 
a ref to an invalid snapshot. In this case we want to signal to a user that no 
explicit snapshot was specified and there is no current main so the `CREATE 
BRANCH` or `TAG` is invalid. Could we just explicitly throw based off that?
   
   On a side note, I'm not sure how we even make it that far into 
TableMetadata, I figured the `createBranch` API would throw an NPE since that 
API requires an explicit `long`



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