apache/seatunnel · error · DatabaseNotExistException
Database ${tablePath.getDatabaseName()} does not exist in ca
Error message
Database ${tablePath.getDatabaseName()} does not exist in catalog ${name()} What it means
createTable(tablePath, table, ignoreIfExists) requires the parent database to exist; if databaseExists(tablePath.getDatabaseName()) is false it throws DatabaseNotExistException. MongoDB does not auto-create databases through this catalog path — you must createDatabase first.
Source
Thrown at seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java:129
public boolean tableExists(TablePath tablePath) throws CatalogException {
try {
return listTables(tablePath.getDatabaseName()).contains(tablePath.getTableName());
} catch (DatabaseNotExistException e) {
return false;
}
}
@Override
public CatalogTable getTable(TablePath tablePath)
throws CatalogException, TableNotExistException {
throw CommonError.unsupportedOperation(name(), "get table with tablePath ");
}
@Override
public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreIfExists)
throws TableAlreadyExistException, DatabaseNotExistException, CatalogException {
if (!databaseExists(tablePath.getDatabaseName())) {
throw new DatabaseNotExistException(name(), tablePath.getDatabaseName());
}
if (tableExists(tablePath)) {
if (ignoreIfExists) return;
throw new TableAlreadyExistException(name(), tablePath);
}
try {
MongoDatabase db = mongoClient.getDatabase(tablePath.getDatabaseName());
db.createCollection(tablePath.getTableName());
} catch (Exception e) {
throw new CatalogException(
"Failed to create collection: " + tablePath.getFullName(), e);
}
}
@Override
public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)
throws TableNotExistException, CatalogException {
if (!tableExists(tablePath)) {View on GitHub (pinned to cf67b549a7)
Solutions
- Call catalog.createDatabase(TablePath.of(db, "_"), true) (or equivalent) before createTable.
- Verify the database name spelling/casing in the table path.
- Ensure the user can list databases; otherwise createDatabase/databaseExists checks fail.
- If the tooling supports it, use ignoreIfExists / create-and-ignore semantics on the parent database.
Example fix
// before
catalog.createTable(TablePath.of("newdb", "coll"), table, true);
// after
catalog.createDatabase(TablePath.of("newdb", "_"), true);
catalog.createTable(TablePath.of("newdb", "coll"), table, true); Defensive patterns
Strategy: validation
Validate before calling
if (!catalog.listDatabases().contains(tablePath.getDatabaseName())) {
catalog.createDatabase(TablePath.of(tablePath.getDatabaseName(), "_"), true);
} Try / catch
try {
catalog.createTable(tablePath, table, ignoreIfExists);
} catch (DatabaseNotExistException e) {
catalog.createDatabase(TablePath.of(tablePath.getDatabaseName(), "_"), true);
catalog.createTable(tablePath, table, ignoreIfExists);
} Prevention
- Always createDatabase before createTable for new databases
- Validate TablePath names against listDatabases output
- Ensure the catalog user can list databases
When it happens
Trigger: Calling createTable for a database that was never created via catalog.createDatabase(), a misspelled database name in the target TablePath, or hidden databases due to insufficient privileges making databaseExists return false.
Common situations: Submitting a SeaTunnel job whose sink table path points to a new database without creating it first; renaming a database in config without creating it; auth-restricted user cannot see the database.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Database ${databaseName} does not exist in catalog ${name()}
- DatabaseNotExistException: catalogName, databaseName
- Database ${databaseName} does not exist in catalog hive
- Database 'null' does not exist in catalog 'null'
- Failed to open MongoDB Catalog: ${e.getMessage()}
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/fe70e9850c057813.
Report an issue: GitHub.