{"record":{"id":"0759e0d855b29e28","repo":"apache/cassandra","slug":"column-s-doesn-t-exist-in-table-s-s","errorCode":null,"errorMessage":"Column '%s' doesn't exist in table '%s.%s'","messagePattern":"Column '(.+?)' doesn't exist in table '(.+?)\\.(.+?)'","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CommentOnColumnStatement.java","lineNumber":81,"sourceCode":"        this.tableName = tableName;\n        this.columnName = columnName;\n    }\n\n    @Override\n    public boolean compatibleWith(ClusterMetadata metadata)\n    {\n        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V8);\n    }\n\n\n    @Override\n    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        TableMetadata table = validateAndGetTable(schema, tableName);\n        ColumnMetadata columnMetadata = table.getColumn(columnName);\n        if (null == columnMetadata)\n            throw ire(\"Column '%s' doesn't exist in table '%s.%s'\", columnName, keyspaceName, tableName);\n\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n        TableMetadata newTable = table.unbuild().alterColumnComment(columnName, effectiveDescription()).build();\n        KeyspaceMetadata newKeyspace = keyspace.withSwapped(keyspace.tables.withSwapped(newTable));\n\n        return schema.withAddedOrUpdated(newKeyspace);\n    }\n\n    @Override\n    SchemaChange schemaChangeEvent(KeyspacesDiff diff)\n    {\n        return new SchemaChange(Change.UPDATED, Target.TABLE, keyspaceName, tableName);\n    }\n\n    @Override\n    public void authorize(ClientState client)\n    {\n        client.ensureTablePermission(keyspaceName, tableName, Permission.ALTER);","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CommentOnColumnStatement.java#L63-L99","documentation":"COMMENT ON COLUMN was issued for a column that does not exist on the specified table. CommentOnColumnStatement.apply() resolves the ColumnMetadata via table.getColumn(columnName) and throws this InvalidRequestException when it returns null. Comments are schema metadata, so the column must already exist.","triggerScenarios":"`COMMENT ON COLUMN <ks>.<table>.<column> IS '...'` where the column name is misspelled, case-sensitive quoting is wrong, the column was dropped, or the table named is a view/index with different columns.","commonSituations":"Documentation-generation scripts referencing outdated schemas; case sensitivity issues for non-lowercase identifiers without quotes; running comments migrations before the column-adding migration.","solutions":["Verify the column exists via `DESCRIBE TABLE` or system_schema.columns","Correct the column name; quote it if it contains mixed case (e.g. \"ColumnName\")","Ensure the migration that adds the column runs before the COMMENT statement","Point the statement at the correct table/keyspace"],"exampleFix":"// before\nCOMMENT ON COLUMN ks.users.Email IS 'user email';\n\n// after\nCOMMENT ON COLUMN ks.users.\"Email\" IS 'user email'; -- or use correct lowercase name email","handlingStrategy":"validation","validationCode":"// Check the column exists first\nconst rows = await session.execute(\n  \"SELECT column_name FROM system_schema.columns WHERE keyspace_name=? AND table_name=? AND column_name=?\",\n  [keyspace, table, columnName]);\nif (rows.rows.length === 0) throw new Error(`Column ${columnName} not found in ${keyspace}.${table}`);","typeGuard":"null","tryCatchPattern":"try {\n  session.execute(`COMMENT ON COLUMN ${ks}.${t}.${c} IS '...'`);\n} catch (e) {\n  if (/Column .* doesn't exist/.test(e.message)) {\n    // run column-adding migration first, then retry\n  } else throw e;\n}","preventionTips":["Query system_schema.columns before commenting","Quote mixed-case column names","Order migrations so column creation precedes comments","Verify table type (table vs view) since column sets differ"],"tags":["cassandra","cql","comment","column-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}