{"record":{"id":"402318d033971aa5","repo":"prestodb/presto","slug":"missing-column-402318","errorCode":"MISSING_COLUMN","errorMessage":"Column '%s' does not exist","messagePattern":"Column '(.+?)' does not exist","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnTypeTask.java","lineNumber":88,"sourceCode":"            }\n            return immediateFuture(null);\n        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            if (!statement.isTableExists()) {\n                throw new SemanticException(SemanticErrorCode.NOT_SUPPORTED, statement, \"'%s' is a materialized view, and alter column is not supported\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        accessControl.checkCanAlterColumn(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        TableHandle tableHandleOptional = tableHandle.get();\n        Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandleOptional);\n        ColumnHandle column = columnHandles.get(statement.getColumnName().getValue());\n        if (column == null) {\n            throw new SemanticException(MISSING_COLUMN, statement, \"Column '%s' does not exist\", statement.getColumnName());\n        }\n        metadata.setColumnType(session, tableHandleOptional, column, getColumnType(statement));\n\n        return immediateFuture(null);\n    }\n\n    private Type getColumnType(SetColumnType statement)\n    {\n        Type type;\n        try {\n            type = metadata.getType(parseTypeSignature(statement.getType()));\n        }\n        catch (IllegalArgumentException e) {\n            throw new SemanticException(TYPE_MISMATCH, statement, \"Unknown type '%s' for column '%s'\", statement.getType(), statement.getColumnName());\n        }\n        if (type.equals(UNKNOWN)) {\n            throw new SemanticException(TYPE_MISMATCH, statement, \"Unknown type '%s' for column '%s'\", statement.getType(), statement.getColumnName());\n        }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnTypeTask.java#L70-L106","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the column exists with SHOW COLUMNS FROM <table> and correct the column name in the ALTER statement.","Check you are targeting the intended catalog.schema.table; qualify the name fully.","If the column was renamed, use the new name or rename it back first."],"exampleFix":"-- before\nALTER TABLE orders ALTER COLUMN cusotmer_id SET TYPE BIGINT\n-- after\nALTER TABLE orders ALTER COLUMN customer_id SET TYPE BIGINT","handlingStrategy":"validation","validationCode":"SHOW COLUMNS FROM catalog.schema.orders; -- confirm the column name exists before ALTER\n-- or programmatically: SELECT column_name FROM information_schema.columns WHERE table_name = 'orders';","typeGuard":"function columnExists(columns, name) {\n  return columns.some(c => c.Column.toLowerCase() === name.toLowerCase());\n}","tryCatchPattern":"try {\n  await run(\"ALTER TABLE orders ALTER COLUMN customer_id SET TYPE BIGINT\");\n} catch (e) {\n  if (e.message.includes(\"does not exist\")) {\n    console.error(`Column not found; run SHOW COLUMNS first: ${e.message}`);\n  }\n  throw e;\n}","preventionTips":["Always run SHOW COLUMNS before ALTER COLUMN statements.","Generate DDL from catalog metadata instead of hand-written column names.","Handle identifier case consistently; qualify catalog.schema.table fully.","Lint migration scripts against current schema snapshots."],"tags":["sql","ddl","presto","missing-column"],"backgroundTag":"missing-column","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}