{"record":{"id":"5ffda1bb331f7325","repo":"prestodb/presto","slug":"missing-column-5ffda1","errorCode":"MISSING_COLUMN","errorMessage":"Insert column name does not exist in target table: %s","messagePattern":"Insert column name does not exist in target table: (.+?)","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java","lineNumber":560,"sourceCode":"                throw new SemanticException(NOT_SUPPORTED, insert, \"Insert into table with column masks is not supported\");\n            }\n\n            List<String> tableColumns = columnsMetadata.stream()\n                    .filter(column -> !column.isHidden())\n                    .map(ColumnMetadata::getName)\n                    .collect(toImmutableList());\n\n            List<String> insertColumns;\n            if (insert.getColumns().isPresent()) {\n                insertColumns = insert.getColumns().get().stream()\n                        .map(Identifier::getValue)\n                        .map(column -> metadata.normalizeIdentifier(session, targetTable.getCatalogName(), column))\n                        .collect(toImmutableList());\n\n                Set<String> columnNames = new HashSet<>();\n                for (String insertColumn : insertColumns) {\n                    if (!tableColumns.contains(insertColumn)) {\n                        throw new SemanticException(MISSING_COLUMN, insert, \"Insert column name does not exist in target table: %s\", insertColumn);\n                    }\n                    if (!columnNames.add(insertColumn)) {\n                        throw new SemanticException(DUPLICATE_COLUMN_NAME, insert, \"Insert column name is specified more than once: %s\", insertColumn);\n                    }\n                }\n            }\n            else {\n                insertColumns = tableColumns;\n            }\n\n            List<ColumnMetadata> expectedColumns = insertColumns.stream()\n                    .map(insertColumn -> getColumnMetadata(columnsMetadata, insertColumn))\n                    .collect(toImmutableList());\n\n            checkTypesMatchForInsert(insert, queryScope, expectedColumns);\n\n            Map<String, ColumnHandle> columnHandles = tableColumnsMetadata.getColumnHandles();\n            analysis.setInsert(new Analysis.Insert(","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java#L542-L578","documentation":"Presto's INSERT analyzer validates that every column name listed in an INSERT INTO t (col1, col2, ...) statement actually exists in the target table. If a listed column name is not found among the table's columns, StatementAnalyzer.visitInsert throws this SemanticException with code MISSING_COLUMN. The name is normalized per the connector (metadata.normalizeIdentifier) before the check.","triggerScenarios":"Running INSERT INTO table (a, b, typo_col) VALUES (...), or INSERT ... SELECT with a column list, where one entry in the column list does not match any column of the target table after identifier normalization (case handling).","commonSituations":"Typos in column names; referring to columns from the SELECT source instead of the target table; case-sensitivity mismatch between quoted identifiers and the connector's normalized names; schema drift where a column was renamed or dropped after the query was written.","solutions":["Run `DESCRIBE <target_table>` (or SHOW COLUMNS FROM) and correct the INSERT column list to match actual column names exactly.","Check identifier quoting: quoted names are case-sensitive for many connectors; match the case shown by DESCRIBE or drop the quotes.","Verify you are connected to the correct catalog/schema/table (fully qualify as catalog.schema.table) so the column list matches the intended table.","If the column was recently renamed or dropped, update the query or re-add the column to the table."],"exampleFix":"// before\nINSERT INTO orders (orderkey, custkey, orderdat) VALUES (1, 2, DATE '2026-01-01');\n// after\nINSERT INTO orders (orderkey, custkey, orderdate) VALUES (1, 2, DATE '2026-01-01');","handlingStrategy":"validation","validationCode":"-- Run before the INSERT:\nDESCRIBE catalog.schema.target_table;\n-- Then verify each name in your INSERT column list appears in the output (respecting case).\nSELECT column_name FROM information_schema.columns\nWHERE table_schema = 'schema' AND table_name = 'target_table';","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always generate INSERT column lists from information_schema/DESCRIBE output instead of hand-typing them.","Keep identifier casing consistent with the connector's normalization rules; avoid mixed quoting.","Fully qualify the table (catalog.schema.table) to avoid validating against the wrong table.","Re-check column lists after any ALTER TABLE rename/drop."],"tags":["sql","insert","semantic-analysis","column-name"],"backgroundTag":"column-not-found","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"}