prestodb/presto · error · SemanticException

MISSING_TABLE

MISSING_TABLE

Error message

View '%s' does not exist

What it means

Thrown by DropViewTask when DROP VIEW references a name for which metadata.getMetadataResolver(session).getView(name) returns empty. The error code is MISSING_TABLE because Presto reuses the missing-relation code for views; if IF EXISTS was given, the task succeeds silently instead.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/DropViewTask.java:52

public class DropViewTask
        implements DDLDefinitionTask<DropView>
{
    @Override
    public String getName()
    {
        return "DROP VIEW";
    }

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

        Optional<ViewDefinition> view = metadata.getMetadataResolver(session).getView(name);
        if (!view.isPresent()) {
            if (!statement.isExists()) {
                throw new SemanticException(MISSING_TABLE, statement, "View '%s' does not exist", name);
            }
            return immediateFuture(null);
        }

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

        metadata.dropView(session, name);

        return immediateFuture(null);
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Confirm the object is a view with SHOW CREATE / information_schema.views
  2. Fix the name or qualify it with the correct catalog.schema
  3. Use DROP VIEW IF EXISTS for idempotent cleanup scripts

Example fix

// before
DROP VIEW daily_agg;
// after
DROP VIEW IF EXISTS reporting.daily_agg;
Defensive patterns

Strategy: validation

Validate before calling

-- confirm the name is a view, not a table
SELECT table_type FROM information_schema.tables
WHERE table_schema = 'my_schema' AND table_name = 'daily_agg';

Try / catch

try { dropView(...); } catch (SemanticException e) { if (e.getCode() == SemanticErrorCode.MISSING_TABLE) { /* already gone; log and continue */ } else { throw e; } }

Prevention

When it happens

Trigger: Executing `DROP VIEW view_name` where no ViewDefinition exists for that QualifiedObjectName and statement.isExists() is false.

Common situations: Dropping a view that was already dropped; confusing a table with a view (DROP VIEW on a table name); wrong schema in the session; case-sensitivity mismatch in quoted identifiers.

Related errors


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