ebyhr commented on code in PR #16061:
URL: https://github.com/apache/iceberg/pull/16061#discussion_r3110141913
##########
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java:
##########
@@ -859,6 +859,25 @@ public void testDropNamespace() {
.hasMessage("Namespace db is not empty. Contains 1 table(s).");
}
+ @Test
+ public void testDropNamespaceWithChildNamespace() {
+ Namespace parent = Namespace.of("parent_ns");
+ Namespace child = Namespace.of("parent_ns", "child_ns");
+
+ // 1. Create the parent and child namespaces
+ catalog.createNamespace(parent);
+ catalog.createNamespace(child);
+
+ // 2. Assert that dropping the parent fails because the child exists
+ assertThatThrownBy(() -> catalog.dropNamespace(parent))
+ .isInstanceOf(NamespaceNotEmptyException.class)
+ .hasMessageStartingWith("Namespace parent_ns is not empty. Contains 1
child namespace(s).");
+
+ // 3. Verify the namespaces still safely exist in the catalog
Review Comment:
nit: I don't think we need to add numeric prefixes. We'd have to renumber
them if we ever insert a new operation in the middle of the code. Comments
might not even be necessary, since the current test code is already simple
enough.
##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -550,6 +550,13 @@ public boolean dropNamespace(Namespace namespace) throws
NamespaceNotEmptyExcept
}
}
+ List<Namespace> childNamespaces = listNamespaces(namespace);
+ if (childNamespaces != null && !childNamespaces.isEmpty()) {
+ throw new NamespaceNotEmptyException(
+ "Namespace %s is not empty. Contains %d child namespace(s).",
+ namespace, childNamespaces.size());
+ }
Review Comment:
Have you confirmed whether other catalogs that support nested namespaces are
experiencing the same issue?
--
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]