prestodb/presto · error · SemanticException

MISSING_TABLE

MISSING_TABLE

Error message

Table '%s' does not exist

What it means

Thrown by DropConstraintTask.execute when DROP CONSTRAINT targets a table that cannot be resolved by the catalog's metadata resolver, and the statement did not include IF EXISTS. Presto throws it before any connector-level drop work begins because there is no TableHandle for the qualified name.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/DropConstraintTask.java:57

public class DropConstraintTask
        implements DDLDefinitionTask<DropConstraint>
{
    @Override
    public String getName()
    {
        return "DROP CONSTRAINT";
    }

    @Override
    public ListenableFuture<?> execute(DropConstraint statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
    {
        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);
        Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);

        if (!tableHandleOptional.isPresent()) {
            if (!statement.isTableExists()) {
                throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
            }
            return immediateFuture(null);
        }

        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);
        if (optionalMaterializedView.isPresent()) {
            if (!statement.isTableExists()) {
                throw new SemanticException(NOT_SUPPORTED, statement, "'%s' is a materialized view, and drop constraint is not supported", tableName);
            }
            return immediateFuture(null);
        }

        ConnectorId connectorId = metadata.getCatalogHandle(session, tableName.getCatalogName())
                .orElseThrow(() -> new PrestoException(NOT_FOUND, "Catalog does not exist: " + tableName.getCatalogName()));
        accessControl.checkCanDropConstraint(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);

        metadata.dropConstraint(session, tableHandleOptional.get(), Optional.of(statement.getConstraintName().toString()), Optional.empty());
        return immediateFuture(null);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the fully qualified table name (catalog.schema.table) exists: SELECT * FROM system_metadata.tables or SHOW TABLES FROM schema.
  2. Add IF EXISTS to the statement if dropping is conditional: DROP CONSTRAINT IF EXISTS ...
  3. Check you are connected to the correct catalog and that the connector still registers the table.

Example fix

// before
DROP CONSTRAINT my_catalog.db.t1 pk_constraint;
// after
DROP CONSTRAINT IF EXISTS my_catalog.db.t1 pk_constraint;
Defensive patterns

Strategy: validation

Validate before calling

// Presto SQL / client-side pre-check
-- run before DROP CONSTRAINT
SELECT table_name FROM <catalog>.information_schema.tables
WHERE table_schema = 'db' AND table_name = 't1';
// if empty, skip or fix the name before issuing DROP CONSTRAINT

Prevention

When it happens

Trigger: Executing 'DROP CONSTRAINT ...' (DropConstraint statement) where metadata.getMetadataResolver(session).getTableHandle(tableName) returns empty and statement.isTableExists() is false.

Common situations: Typo in table name; table dropped by another session; wrong catalog/schema in the qualified name; connector that does not expose the table (e.g. view mapped differently); case-sensitivity mismatches with quoted identifiers.

Related errors


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