prestodb/presto · error · SemanticException

MISSING_TABLE

MISSING_TABLE

Error message

Table '%s' does not exist

What it means

SemanticException thrown by RenameColumnTask.execute when ALTER TABLE ... RENAME COLUMN targets a table that does not exist in the catalog. Presto resolves the qualified table name via the metadata resolver before performing the rename; a missing table aborts the statement. If the statement used IF EXISTS, no error is thrown and the task becomes a no-op.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/RenameColumnTask.java:58

import static com.google.common.util.concurrent.Futures.immediateFuture;

public class RenameColumnTask
        implements DDLDefinitionTask<RenameColumn>
{
    @Override
    public String getName()
    {
        return "RENAME COLUMN";
    }

    @Override
    public ListenableFuture<?> execute(RenameColumn 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 rename column is not supported", tableName);
            }
            return immediateFuture(null);
        }

        TableHandle tableHandle = tableHandleOptional.get();

        Identifier sourceName = statement.getSource();
        String source = metadata.normalizeIdentifier(session, tableName.getCatalogName(), sourceName.getValue());
        Identifier targetName = statement.getTarget();
        String target = metadata.normalizeIdentifier(session, tableName.getCatalogName(), targetName.getValue());

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the fully qualified table name (catalog.schema.table) with SHOW TABLES in the target schema
  2. Add IF EXISTS if the drop-before-rename race is acceptable: ALTER TABLE IF EXISTS ... RENAME COLUMN
  3. Confirm you are connected to the intended catalog (USE catalog.schema) and environment
  4. Check permissions/environment: the connector may hide tables the current user cannot see

Example fix

-- before
ALTER TABLE shop.orders RENANE COLUMN cust_id TO customer_id; -- table 'shop.orders' typo'd
-- after
ALTER TABLE IF EXISTS shop.orders RENAME COLUMN cust_id TO customer_id;
Defensive patterns

Strategy: validation

Validate before calling

// before running ALTER TABLE ... RENAME COLUMN
ResultSet rs = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE table_catalog='shop' AND table_schema='public' AND table_name='orders'");
boolean exists = rs.next();

Try / catch

try {
    execute("ALTER TABLE shop.orders RENAME COLUMN ... ");
} catch (SemanticException e) {
    if (e.getCode() == MISSING_TABLE) {
        // skip: table absent (already migrated)
    } else throw e;
}

Prevention

When it happens

Trigger: ALTER TABLE ... RENAME COLUMN where metadata.getTableHandle(tableName) returns empty and statement.isTableExists() (IF EXISTS) is false. Includes wrong catalog/schema qualification or a typo in the table name.

Common situations: Typo in table name; table lives in a different catalog/schema than assumed; table was dropped by another process; connecting to the wrong environment (test vs prod catalog).

Related errors


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