prestodb/presto · error · SemanticException

MISSING_SCHEMA

MISSING_SCHEMA

Error message

Schema name is empty

What it means

In the same populateMetadataHandle loop, after validating the object name, MetadataExtractor validates the schema part of each collected QualifiedObjectName. An empty schemaName triggers MISSING_SCHEMA because a catalog-local, schema-less name cannot be resolved to view definitions.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/MetadataExtractor.java:84

    public void populateMetadataHandle(Session session, Statement statement, MetadataHandle metadataHandle)
    {
        if (executor.isPresent() && isPreProcessMetadataCalls(session)) {
            metadataHandle.setPreProcessMetadataCalls(true);
            populateMetadataHandle(session, statement, metadataHandle, new MetadataExtractorContext());
        }
    }

    private void populateMetadataHandle(Session session, Statement statement, MetadataHandle metadataHandle, MetadataExtractorContext metadataExtractorContext)
    {
        Visitor visitor = new Visitor(session);
        visitor.process(statement, metadataExtractorContext);

        metadataExtractorContext.getTableNames().forEach(tableName -> {
            if (tableName.getObjectName().isEmpty()) {
                throw new SemanticException(MISSING_TABLE, "Table name is empty");
            }
            if (tableName.getSchemaName().isEmpty()) {
                throw new SemanticException(MISSING_SCHEMA, "Schema name is empty");
            }

            metadataHandle.addViewDefinition(tableName, executor.get().submit(() -> {
                Optional<ViewDefinition> optionalView = session.getRuntimeStats().recordWallTime(
                        GET_VIEW_TIME_NANOS,
                        () -> metadataResolver.getView(tableName));
                if (optionalView.isPresent()) {
                    ViewDefinition view = optionalView.get();
                    Statement viewStatement = sqlParser.createStatement(view.getOriginalSql(), createParsingOptions(session, warningCollector));
                    Session.SessionBuilder viewSessionBuilder = Session.builder(metadata.getSessionPropertyManager())
                            .setQueryId(session.getQueryId())
                            .setRuntimeStats(session.getRuntimeStats())
                            .setTransactionId(session.getTransactionId().orElse(null))
                            .setIdentity(session.getIdentity())
                            .setSource(session.getSource().orElse(null))
                            .setCatalog(view.getCatalog().orElse(null))
                            .setSchema(view.getSchema().orElse(null))
                            .setTimeZoneKey(session.getTimeZoneKey())

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fully qualify the table reference with its schema: catalog.schema.table.
  2. Set a default schema for the session if the connector supports one, so unqualified names resolve correctly.
  3. Fix the upstream generator/templating that drops the schema segment.

Example fix

// before
SELECT * FROM events;
// after
SELECT * FROM hive.default.events;
Defensive patterns

Strategy: validation

Validate before calling

// require the schema segment before executing
function assertQualified(name) {
  const parts = name.split(".").filter(Boolean);
  if (parts.length < 2) throw new Error("Reference must include schema: catalog.schema.table");
}

Prevention

When it happens

Trigger: A referenced table/view name resolves to a QualifiedObjectName with an empty schema component — e.g. a one-part name that the connector mapped to a catalog but no schema.

Common situations: Omitting the schema when one is required by the connector; generated SQL missing the schema segment; cross-catalog references where the schema was accidentally dropped.

Related errors


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