prestodb/presto · error · SemanticException

MISSING_CATALOG

MISSING_CATALOG

Error message

Catalog '${catalogName}' does not exist

What it means

SHOW TABLES first resolves the target catalog via createCatalogSchemaName (which falls back to the session catalog). If neither the statement nor the session specifies a catalog that exists, metadataResolver.catalogExists fails and a SemanticException MISSING_CATALOG is thrown for the SHOW TABLES statement.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:240

        {
            Statement statement = (Statement) process(node.getStatement(), null);
            return new Explain(
                    node.getLocation().get(),
                    node.isAnalyze(),
                    node.isVerbose(),
                    statement,
                    node.getOptions());
        }

        @Override
        protected Node visitShowTables(ShowTables showTables, Void context)
        {
            CatalogSchemaName schema = createCatalogSchemaName(session, showTables, showTables.getSchema(), metadata);

            accessControl.checkCanShowTablesMetadata(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), schema);

            if (!metadataResolver.catalogExists(schema.getCatalogName())) {
                throw new SemanticException(MISSING_CATALOG, showTables, "Catalog '%s' does not exist", schema.getCatalogName());
            }

            if (!metadataResolver.schemaExists(schema)) {
                throw new SemanticException(MISSING_SCHEMA, showTables, "Schema '%s' does not exist", schema.getSchemaName());
            }

            Expression predicate = equal(identifier("table_schema"), new StringLiteral(schema.getSchemaName()));

            Optional<String> likePattern = showTables.getLikePattern();
            if (likePattern.isPresent()) {
                Expression likePredicate = new LikePredicate(
                        identifier("table_name"),
                        new StringLiteral(likePattern.get()),
                        showTables.getEscape().map(StringLiteral::new));
                predicate = logicalAnd(predicate, likePredicate);
            }

            return simpleQuery(

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fully qualify the schema: `SHOW TABLES FROM <catalog>.<schema>`, with the catalog spelled correctly.
  2. Set the session catalog first: `USE <catalog>.<schema>` then run SHOW TABLES.
  3. Verify the catalog exists (check etc/catalog/*.properties and that the connector loaded).
  4. Reconnect choosing a default catalog in the client if the tool supports it.

Example fix

// before
SHOW TABLES FROM myschema            -- no session catalog
// after
SHOW TABLES FROM hive.myschema
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the catalog exists before SHOW TABLES
boolean exists = client.execute("SELECT 1 FROM system.metadata.catalogs WHERE catalog_name = '" + catalog + "'").hasRows();
if (!exists) throw new IllegalArgumentException("Catalog not found: " + catalog);

Try / catch

try {
    session.execute("SHOW TABLES FROM " + schema);
} catch (SemanticException e) {
    if (e.getCode() == SemanticErrorCode.MISSING_CATALOG) {
        // prompt for catalog or list: SHOW CATALOGS
    } else throw e;
}

Prevention

When it happens

Trigger: Running `SHOW TABLES FROM schema` (or `SHOW TABLES`) while the session's catalog is unset or names a nonexistent catalog, so schema.getCatalogName() does not exist in the metadata resolver.

Common situations: Connecting without setting a default catalog; typo in catalog name in `SHOW TABLES FROM cat.schema`; catalog removed/unloaded after a connector config change.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/a350a31323528ee9. Report an issue: GitHub.