Skip to content
Merged
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 @@ -160,7 +160,8 @@ public void dropDb(DropDbStmt stmt) throws DdlException {
return null;
});
} catch (Exception e) {
throw new DdlException("Failed to drop database: " + stmt.getDbName() + " ,error message is: ", e);
throw new DdlException(
"Failed to drop database: " + stmt.getDbName() + ", error message is: " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.doris.analysis.CreateDbStmt;
import org.apache.doris.analysis.CreateTableStmt;
import org.apache.doris.analysis.DbName;
import org.apache.doris.analysis.DropDbStmt;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.UserException;
import org.apache.doris.datasource.CatalogFactory;
import org.apache.doris.nereids.parser.NereidsParser;
Expand Down Expand Up @@ -201,4 +203,28 @@ public String getTableName() {
String s = "test_tb_" + UUID.randomUUID();
return s.replaceAll("-", "");
}

@Test
public void testDropDB() {
String dbName = "db_to_delete";
CreateDbStmt createDBStmt = new CreateDbStmt(false, new DbName("iceberg", dbName), new HashMap<>());
DropDbStmt dropDbStmt = new DropDbStmt(false, new DbName("iceberg", dbName), false);
DropDbStmt dropDbStmt2 = new DropDbStmt(false, new DbName("iceberg", "not_exists"), false);
try {
// create db success
ops.createDb(createDBStmt);
// drop db success
ops.dropDb(dropDbStmt);
} catch (Throwable t) {
Assert.fail();
}

try {
ops.dropDb(dropDbStmt2);
Assert.fail();
} catch (Throwable t) {
Assert.assertTrue(t instanceof DdlException);
Assert.assertTrue(t.getMessage().contains("database doesn't exist"));
}
}
}
Loading