kbendick commented on a change in pull request #3573:
URL: https://github.com/apache/iceberg/pull/3573#discussion_r752020482
##########
File path:
spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestNamespaceSQL.java
##########
@@ -100,12 +97,94 @@ public void testDropNonEmptyNamespace() {
Assert.assertTrue("Table should exist",
validationCatalog.tableExists(TableIdentifier.of(NS, "table")));
AssertHelpers.assertThrows("Should fail if trying to delete a non-empty
namespace",
- SparkException.class, "non-empty namespace",
+ Exception.class, "empty",
() -> sql("DROP NAMESPACE %s", fullNamespace));
sql("DROP TABLE %s.table", fullNamespace);
}
+ @Test
+ public void testDropNonEmptyNamespaceOnCascade() {
+ Assert.assertFalse("Namespace should not already exist",
validationNamespaceCatalog.namespaceExists(NS));
+
+ sql("CREATE NAMESPACE %s", fullNamespace);
+ sql("CREATE TABLE %s.table (id bigint) USING iceberg", fullNamespace);
+
+ Assert.assertTrue("Namespace should exist",
validationNamespaceCatalog.namespaceExists(NS));
+ Assert.assertTrue("Table should exist",
validationCatalog.tableExists(TableIdentifier.of(NS, "table")));
+
+ AssertHelpers.assertThrows("Should fail if trying to delete a non-empty
namespace",
+ Exception.class, "empty",
+ () -> sql("DROP NAMESPACE %s", fullNamespace));
+
+ List<Object[]> namespaces = sql("SHOW NAMESPACES IN %s", catalogName);
+ if (isHadoopCatalog) {
+ Assert.assertEquals("Should have 1 namespace", 1, namespaces.size());
+ Set<String> namespaceNames = namespaces.stream().map(arr ->
arr[0].toString()).collect(Collectors.toSet());
+ Assert.assertEquals("Should have only db namespace",
ImmutableSet.of("db"), namespaceNames);
+ } else {
+ Assert.assertEquals("Should have 2 namespaces", 2, namespaces.size());
+ Set<String> namespaceNames = namespaces.stream().map(arr ->
arr[0].toString()).collect(Collectors.toSet());
+ Assert.assertEquals("Should have default and db namespaces",
ImmutableSet.of("default", "db"), namespaceNames);
+ }
+
+ sql("SHOW NAMESPACES in %s", catalogName).forEach(System.err::println);
Review comment:
TODO - Need to remove this from debugging. Not doing it now so tests can
run to completion but will do it in the AM.
--
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]