ajantha-bhat commented on code in PR #4700:
URL: https://github.com/apache/iceberg/pull/4700#discussion_r866698958
##########
nessie/src/test/java/org/apache/iceberg/nessie/TestBranchVisibility.java:
##########
@@ -398,4 +402,39 @@ private void testCatalogEquality(
assertion.isNotEqualTo(testTable2);
}
}
+
+ @Test
+ public void testWithRefAndHash() throws NessieConflictException,
NessieNotFoundException {
+ String testBranch = "testBranch";
+ createBranch(testBranch, null);
+ Schema schema = new Schema(Types.StructType.of(required(1, "id",
Types.LongType.get())).fields());
+
+ NessieCatalog nessieCatalog = initCatalog(testBranch);
+ String hashBeforeNamespaceCreation =
api.getReference().refName(testBranch).get().getHash();
+ Namespace namespace = Namespace.of("a", "b");
+ Assertions.assertThat(nessieCatalog.listNamespaces(namespace)).isEmpty();
+
+ nessieCatalog.createNamespace(namespace);
+
Assertions.assertThat(nessieCatalog.listNamespaces(namespace)).isNotEmpty();
+ Assertions.assertThat(nessieCatalog.listTables(namespace)).isEmpty();
+
+ NessieCatalog catalogAtHash1 = initCatalog(testBranch,
hashBeforeNamespaceCreation);
+ Assertions.assertThat(catalogAtHash1.listNamespaces(namespace)).isEmpty();
+ Assertions.assertThat(catalogAtHash1.listTables(namespace)).isEmpty();
+
+ TableIdentifier identifier = TableIdentifier.of(namespace, "table");
+ String hashBeforeTableCreation = nessieCatalog.currentHash();
+ nessieCatalog.createTable(identifier, schema);
+ Assertions.assertThat(nessieCatalog.listTables(namespace)).hasSize(1);
+
+ NessieCatalog catalogAtHash2 = initCatalog(testBranch,
hashBeforeTableCreation);
+
Assertions.assertThat(catalogAtHash2.listNamespaces(namespace)).isNotEmpty();
+ Assertions.assertThat(catalogAtHash2.listTables(namespace)).isEmpty();
+
+ // updates should not be possible
+ Assertions.assertThatThrownBy(() -> catalogAtHash2.createTable(identifier,
schema))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("You can only mutate tables when using a branch
without a hash or timestamp.");
+ Assertions.assertThat(catalogAtHash2.listTables(namespace)).isEmpty();
Review Comment:
Can we add one more case of init catalog ref with head and try commit
(create table) just after this line and commit should succeed ?
--
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]