prestodb/presto · error · SemanticException

MISSING_COLUMN

MISSING_COLUMN

Error message

Column '%s' does not exist

What it means

This error is thrown by Presto's ALTER COLUMN ... SET TYPE handler when the named column does not exist in the target table. After resolving all column handles for the table, the handler looks up the statement's column name; a null lookup means the column is missing, so a SemanticException(MISSING_COLUMN) is raised before any metadata change. It prevents altering a column that the connector does not recognize.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnTypeTask.java:88

            }
            return immediateFuture(null);
        }

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

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

        TableHandle tableHandleOptional = tableHandle.get();
        Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandleOptional);
        ColumnHandle column = columnHandles.get(statement.getColumnName().getValue());
        if (column == null) {
            throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", statement.getColumnName());
        }
        metadata.setColumnType(session, tableHandleOptional, column, getColumnType(statement));

        return immediateFuture(null);
    }

    private Type getColumnType(SetColumnType statement)
    {
        Type type;
        try {
            type = metadata.getType(parseTypeSignature(statement.getType()));
        }
        catch (IllegalArgumentException e) {
            throw new SemanticException(TYPE_MISMATCH, statement, "Unknown type '%s' for column '%s'", statement.getType(), statement.getColumnName());
        }
        if (type.equals(UNKNOWN)) {
            throw new SemanticException(TYPE_MISMATCH, statement, "Unknown type '%s' for column '%s'", statement.getType(), statement.getColumnName());
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the column exists with SHOW COLUMNS FROM <table> and correct the column name in the ALTER statement.
  2. Check you are targeting the intended catalog.schema.table; qualify the name fully.
  3. If the column was renamed, use the new name or rename it back first.

Example fix

-- before
ALTER TABLE orders ALTER COLUMN cusotmer_id SET TYPE BIGINT
-- after
ALTER TABLE orders ALTER COLUMN customer_id SET TYPE BIGINT
Defensive patterns

Strategy: validation

Validate before calling

SHOW COLUMNS FROM catalog.schema.orders; -- confirm the column name exists before ALTER
-- or programmatically: SELECT column_name FROM information_schema.columns WHERE table_name = 'orders';

Type guard

function columnExists(columns, name) {
  return columns.some(c => c.Column.toLowerCase() === name.toLowerCase());
}

Try / catch

try {
  await run("ALTER TABLE orders ALTER COLUMN customer_id SET TYPE BIGINT");
} catch (e) {
  if (e.message.includes("does not exist")) {
    console.error(`Column not found; run SHOW COLUMNS first: ${e.message}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running ALTER TABLE <table> ALTER COLUMN <name> SET TYPE <type> where the column name does not match any column of the table (typo, wrong case, or referencing a different table).

Common situations: Typos in column names; case sensitivity mismatches (Presto identifiers are case-insensitive only to a point depending on the connector); running the ALTER against a table in the wrong catalog/schema; the column was dropped or renamed by another process.

Related errors


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