prestodb/presto · error · SemanticException

MISSING_CATALOG

MISSING_CATALOG

Error message

Catalog '%s' does not exist

What it means

CreateViewTask.execute resolves the target view name to a QualifiedObjectName and verifies the catalog exists via metadataResolver.catalogExists. If the catalog portion of the qualified name does not exist, it throws SemanticException(MISSING_CATALOG). This is a fail-fast check before schema or permission checks.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/CreateViewTask.java:97

    public String getName()
    {
        return "CREATE VIEW";
    }

    @Override
    public String explain(CreateView statement, List<Expression> parameters)
    {
        return "CREATE VIEW " + statement.getName();
    }

    @Override
    public ListenableFuture<?> execute(CreateView statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
    {
        QualifiedObjectName name = createQualifiedObjectName(session, statement, statement.getName(), metadata);
        MetadataResolver metadataResolver = metadata.getMetadataResolver(session);

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

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

        accessControl.checkCanCreateView(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), name);

        String sql = getFormattedSql(statement.getQuery(), sqlParser, Optional.of(parameters));

        Analysis analysis = analyzeStatement(statement, session, metadata, accessControl, parameters, warningCollector, query);

        List<ViewColumn> columns = analysis.getOutputDescriptor(statement.getQuery())
                .getVisibleFields().stream()
                .map(field -> new ViewColumn(field.getName().get(), field.getType()))
                .collect(toImmutableList());

        List<ColumnMetadata> columnMetadata = columns.stream()

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Run SHOW CATALOGS and use an existing catalog name in the CREATE VIEW statement.
  2. Check the coordinator's etc/catalog/ directory to confirm the intended catalog is configured, and restart/redeploy if it is missing.
  3. Fix the typo in the qualified name (e.g. hive.web.page_views instead of hve.web.page_views).

Example fix

// before
CREATE VIEW prod1.analytics.daily AS SELECT ...;
// after (catalog 'prod1' does not exist; actual catalog is 'prod')
CREATE VIEW prod.analytics.daily AS SELECT ...;
Defensive patterns

Strategy: validation

Validate before calling

-- Validate catalog before CREATE VIEW
SHOW CATALOGS LIKE 'prod';
-- programmatic: query system.metadata.catalogs
SELECT catalog_name FROM system.metadata.catalogs WHERE catalog_name = 'prod';

Type guard

function catalogExists(session, name) {
  return session.execute('SELECT count(*) FROM system.metadata.catalogs WHERE catalog_name = ?', [name.catalog]) > 0;
}

Try / catch

try {
  session.execute(createViewSql);
} catch (e) {
  if (e.message.includes("does not exist") && e.message.startsWith("Catalog")) {
    // surface list of available catalogs: SHOW CATALOGS
  }
  throw e;
}

Prevention

When it happens

Trigger: Executing CREATE VIEW <catalog>.<schema>.<name> where <catalog> is not a registered/configured catalog in the Presto cluster.

Common situations: Typo in catalog name; connecting to a cluster that lacks a catalog configured on the coordinator; copying SQL from an environment with different catalogs; catalog removed from etc/catalog after a restart.

Related errors


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