{"record":{"id":"1eadcdde16bc8efa","repo":"prestodb/presto","slug":"missing-column-1eadcd","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/SetColumnDefaultTask.java","lineNumber":81,"sourceCode":"        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            if (!statement.isTableExists()) {\n                throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, and set column default is not supported\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        TableHandle tableHandle = tableHandleOptional.get();\n        String columnName = metadata.normalizeIdentifier(session, tableName.getCatalogName(), statement.getColumn().getValue());\n\n        accessControl.checkCanAlterColumn(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);\n        ColumnHandle columnHandle = columnHandles.get(columnName);\n        if (columnHandle == null) {\n            throw new SemanticException(MISSING_COLUMN, statement, \"Column '%s' does not exist\", columnName);\n        }\n\n        ColumnMetadata columnMetadata = metadata.getColumnMetadata(session, tableHandle, columnHandle);\n        if (columnMetadata.isHidden()) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"Cannot set default on hidden column\");\n        }\n\n        // Evaluate the default expression\n        Type columnType = columnMetadata.getType();\n        Expression defaultExpr = statement.getDefaultExpression();\n        Object defaultValue = ExpressionInterpreter.evaluateConstantExpression(defaultExpr, columnType, metadata, session, ImmutableMap.of());\n\n        // Call the metadata method to set the write-default\n        metadata.setColumnDefault(session, tableHandle, columnName, defaultValue);\n\n        return immediateFuture(null);\n    }\n}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/SetColumnDefaultTask.java#L63-L99","documentation":"Before applying a column default, Presto resolves the (normalized) column name to a ColumnHandle via metadata.getColumnHandles. A missing handle means the column is not part of the table, so the ALTER fails with MISSING_COLUMN. Names are normalized per the connector's identifier rules before the lookup.","triggerScenarios":"ALTER TABLE ... ALTER COLUMN <name> SET DEFAULT where columnName is absent from the table's column handle map — misspelled column, wrong case beyond normalization, or the column was dropped.","commonSituations":"Case-sensitivity mismatches with quoted identifiers; column renamed by a migration; running the ALTER against an older schema version of the table.","solutions":["Check the table's column names (DESCRIBE / SHOW COLUMNS) and fix the column name","Quote the identifier if case matters for the connector","Re-add the column if it was dropped"],"exampleFix":"// before\nALTER TABLE hive.default.orders ALTER COLUMN ammount SET DEFAULT 0;\n// after\nALTER TABLE hive.default.orders ALTER COLUMN amount SET DEFAULT 0;","handlingStrategy":"validation","validationCode":"String columnName = metadata.normalizeIdentifier(session, catalog, column.getValue());\nMap<String, ColumnHandle> handles = metadata.getColumnHandles(session, tableHandle);\nif (!handles.containsKey(columnName)) {\n    throw new IllegalArgumentException(\"Column not found on \" + tableName + \": \" + columnName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return task.execute(stmt, ...);\n} catch (SemanticException e) {\n    if (e.getCode() == SemanticErrorCode.MISSING_COLUMN) {\n        // surface a friendly 'column not found' message\n    } else {\n        throw e;\n    }\n}","preventionTips":["Run DESCRIBE <table> to confirm exact column names and casing","Quote identifiers where the connector is case-sensitive","Update DDL after column renames in migrations"],"tags":["sql","alter-table","column-not-found","semantic-error"],"backgroundTag":"column-does-not-exist","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"}