hililiwei commented on code in PR #6638: URL: https://github.com/apache/iceberg/pull/6638#discussion_r1090533942
########## spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestCreateBranch.java: ########## @@ -129,6 +129,24 @@ public void testCreateBranchUseCustomMaxSnapshotAge() throws NoSuchTableExceptio Assert.assertNull(ref.maxRefAgeMs()); } + @Test + public void testCreateBranchIfNotExists() throws NoSuchTableException { + long maxSnapshotAge = 2L; + Table table = createDefaultTableAndInsert2Row(); + String branchName = "b1"; + sql( + "ALTER TABLE %s CREATE BRANCH %s WITH SNAPSHOT RETENTION %d DAYS", + tableName, branchName, maxSnapshotAge); + sql("ALTER TABLE %s CREATE BRANCH IF NOT EXISTS %s", tableName, branchName); + + table.refresh(); + SnapshotRef ref = table.refs().get(branchName); + Assert.assertNotNull(ref); Review Comment: ```suggestion Assert.assertEquals(table.currentSnapshot().snapshotId(), ref.snapshotId()); ``` -- 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