apache/seatunnel · error · DatabaseNotExistException

Database ${databaseName} does not exist in catalog hive

Error message

Database ${databaseName} does not exist in catalog hive

What it means

Thrown by listTables() as a DatabaseNotExistException when databaseExists(databaseName) returns false before querying getAllTables(). It means the named database is absent from the Hive Metastore the catalog is connected to.

Source

Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java:595

    @Override
    public List<String> listDatabases() throws CatalogException {
        try {
            return getClient().getAllDatabases();
        } catch (TException e) {
            log.warn(
                    "listDatabases failed via getAllDatabases(), check HMS version compatibility: {}",
                    e.getMessage());
            throw new CatalogException("Failed to list databases", e);
        }
    }

    @Override
    public List<String> listTables(String databaseName)
            throws CatalogException, DatabaseNotExistException {
        try {
            if (!databaseExists(databaseName)) {
                throw new DatabaseNotExistException("hive", databaseName);
            }
            return getClient().getAllTables(databaseName);
        } catch (TException e) {
            throw new CatalogException("Failed to list tables in database: " + databaseName, e);
        }
    }

    @Override
    public boolean tableExists(TablePath tablePath) throws CatalogException {
        return tableExists(tablePath.getDatabaseName(), tablePath.getTableName());
    }

    @Override
    public CatalogTable getTable(TablePath tablePath)
            throws CatalogException, TableNotExistException {
        try {
            if (!tableExists(tablePath.getDatabaseName(), tablePath.getTableName())) {
                throw new TableNotExistException("hive", tablePath);

View on GitHub (pinned to cf67b549a7)

Solutions

  1. List existing databases via listDatabases() or `SHOW DATABASES` in Hive and use an exact existing name.
  2. Check that hive-conf-dir/metastore URI points to the cluster where the database actually exists.
  3. Create the database (CREATE DATABASE) if it is genuinely missing.

Example fix

// before
List<String> tables = catalog.listTables("Prod_Sales");
// after: use exact lowercase name verified via listDatabases
List<String> dbs = catalog.listDatabases();
if (dbs.contains("prod_sales")) {
    List<String> tables = catalog.listTables("prod_sales");
}
Defensive patterns

Strategy: validation

Validate before calling

if (!catalog.databaseExists(databaseName)) {
    throw new IllegalArgumentException("Database not found: " + databaseName);
}
List<String> tables = catalog.listTables(databaseName);

Try / catch

try {
    return catalog.listTables(db);
} catch (DatabaseNotExistException e) {
    return List.of(); // or surface a friendly message
}

Prevention

When it happens

Trigger: Calling listTables(databaseName) (or any flow that enumerates tables) with a database name that does not exist in HMS — typically a typo, wrong case, or a database that lives in a different metastore environment.

Common situations: Typo or case mismatch (Hive database names are usually lowercase); pointing the connector at a dev/test metastore while expecting prod databases; database was dropped between plan and execution.

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


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/2f157c783e44f5dc. Report an issue: GitHub.