prestodb/presto · error · SemanticException

MISSING_TABLE

MISSING_TABLE

Error message

Table '%s' does not exist

What it means

DropColumnTask.execute resolves the table handle for ALTER TABLE ... DROP COLUMN. If getTableHandle returns empty the table does not exist; unless IF EXISTS was given, it throws SemanticException(MISSING_TABLE). With IF EXISTS it silently returns.

Source

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

public class DropColumnTask
        implements DDLDefinitionTask<DropColumn>
{
    @Override
    public String getName()
    {
        return "DROP COLUMN";
    }

    @Override
    public ListenableFuture<?> execute(DropColumn statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
    {
        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable(), 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 column is not supported", tableName);
            }
            return immediateFuture(null);
        }

        TableHandle tableHandle = tableHandleOptional.get();
        Identifier columnIdentifier = statement.getColumn();
        String column = metadata.normalizeIdentifier(session, tableName.getCatalogName(), columnIdentifier.getValue());

        accessControl.checkCanDropColumn(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the table exists via SHOW TABLES / SHOW CREATE and fix the name.
  2. Use IF EXISTS (ALTER TABLE ... DROP COLUMN ... requires the table-level IF EXISTS supported by this syntax) to make the operation idempotent.
  3. Check that you are connected to the intended catalog/schema.

Example fix

// before
ALTER TABLE hive.default.events DROP COLUMN temp_flag; -- table gone
// after
DROP TABLE IF EXISTS ...; -- or re-create
ALTER TABLE hive.default.events_backup DROP COLUMN temp_flag;
Defensive patterns

Strategy: validation

Validate before calling

-- Confirm table exists before DROP COLUMN
SELECT table_name FROM information_schema.tables
WHERE table_catalog = 'hive' AND table_schema = 'default' AND table_name = 'events';

Try / catch

try {
  session.execute(alterDropColumnSql);
} catch (e) {
  if (/Table '.*' does not exist/.test(e.message)) {
    log.warn(`Table missing, skipping: ${e.message}`);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Executing ALTER TABLE <name> DROP COLUMN <col> (without IF EXISTS) where the connector cannot resolve the table name to a TableHandle.

Common situations: Typo or wrong case in table name; table already dropped in a concurrent session; referencing a view/materialized-view name expecting table behavior; wrong catalog/schema qualification in multi-tenant scripts.

Related errors


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