Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,23 @@ void beforeEach() throws Exception {
mockLakeCatalog);
catalog.open();

// First check if database exists, and drop it if it does
// Clean up any leftover tables from previous tests
if (catalog.databaseExists(DEFAULT_DB)) {
catalog.dropDatabase(DEFAULT_DB, true, true);
}
try {
catalog.createDatabase(
DEFAULT_DB, new CatalogDatabaseImpl(Collections.emptyMap(), null), true);
} catch (CatalogException e) {
// the auto partitioned manager may create the db zk node
// in another thread, so if exception is NodeExistsException, just ignore
if (!ExceptionUtils.findThrowableWithMessage(e, "KeeperException$NodeExistsException")
.isPresent()) {
throw e;
for (String table : catalog.listTables(DEFAULT_DB)) {
catalog.dropTable(new ObjectPath(DEFAULT_DB, table), true);
}
} else {
try {
catalog.createDatabase(
DEFAULT_DB, new CatalogDatabaseImpl(Collections.emptyMap(), null), true);
} catch (CatalogException e) {
// the auto partitioned manager may create the db zk node
// in another thread, so if exception is NodeExistsException, just ignore
if (!ExceptionUtils.findThrowableWithMessage(
e, "KeeperException$NodeExistsException")
.isPresent()) {
throw e;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ public Map<String, PartitionRegistration> listPartitions(

public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade)
throws DatabaseNotExistException, DatabaseNotEmptyException {
if (CoordinatorServer.DEFAULT_DATABASE.equals(name)) {
throw new UnsupportedOperationException(
"Cannot drop the default database '"
+ name
+ "'. The default database is required for cluster operation.");
}
if (!databaseExists(name)) {
if (ignoreIfNotExists) {
return;
Expand Down