{"record":{"id":"b89945aa940d6af4","repo":"apache/cassandra","slug":"undefined-column-name-s-in-table-s","errorCode":null,"errorMessage":"Undefined column name %s in table %s","messagePattern":"Undefined column name (.+?) in table (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/TableMetadata.java","lineNumber":540,"sourceCode":"    }\n\n    /**\n     * Returns the column of the provided name if it exists, but throws a user-visible exception if that column doesn't\n     * exist.\n     *\n     * <p>This method is for finding columns from a name provided by the user, and as such it does _not_ returne hidden\n     * columns (throwing that the column is unknown instead).\n     *\n     * @param name the name of an existing non-hidden column of this table.\n     * @return the column metadata corresponding to {@code name}.\n     *\n     * @throws InvalidRequestException if there is no non-hidden column named {@code name} in this table.\n     */\n    public ColumnMetadata getExistingColumn(ColumnIdentifier name)\n    {\n        ColumnMetadata def = getColumn(name);\n        if (def == null)\n            throw new InvalidRequestException(format(UNDEFINED_COLUMN_NAME_MESSAGE, name.toCQLString(), this));\n        return def;\n    }\n    /*\n     * In general it is preferable to work with ColumnIdentifier to make it\n     * clear that we are talking about a CQL column, not a cell name, but there\n     * is a few cases where all we have is a ByteBuffer (when dealing with IndexExpression\n     * for instance) so...\n     */\n    public ColumnMetadata getColumn(ByteBuffer name)\n    {\n        return columns.get(name);\n    }\n\n    public ColumnMetadata getColumnById(int uniqueId)\n    {\n        return columnsById[uniqueId];\n    }\n","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/TableMetadata.java#L522-L558","documentation":"Thrown as an InvalidRequestException by TableMetadata.getExistingColumn when no non-hidden column with the given identifier exists in the table. It surfaces invalid column references (in SELECT, INSERT, index definitions, etc.) as clear user errors.","triggerScenarios":"Calling getExistingColumn/getColumnMetadata/getColumnsMetadata with a ColumnIdentifier that does not match any column in the table — typically from query validation of a CQL statement referencing a misspelled or nonexistent column.","commonSituations":"Typo in a column name in a CQL query; querying a column that exists only in another table/schema version; referencing a column after a schema change that dropped it; stale prepared statements after DROP of a column.","solutions":["Check the column name against DESCRIBE TABLE / system_schema.columns for the table","Correct the spelling or casing of the column identifier","Refresh schema agreement if the client's schema metadata is stale after an ALTER","Re-prepare statements after schema changes"],"exampleFix":"// before\nSELECT usr_name FROM my_ks.users WHERE id = ?;\n// after\nSELECT user_name FROM my_ks.users WHERE id = ?;","handlingStrategy":"validation","validationCode":"ColumnMetadata col = tableMetadata.getColumn(ColumnIdentifier.getInternedIdentifier(name)); if (col == null) throw new IllegalArgumentException(\"Unknown column \" + name + \" in \" + tableMetadata);","typeGuard":"null","tryCatchPattern":"try { ColumnMetadata c = table.getExistingColumn(identifier); ... } catch (InvalidRequestException e) { throw new QueryValidationError(e.getMessage(), e); }","preventionTips":["Validate column names against system_schema.columns before executing","Keep client-side schema metadata in sync (check schema agreement)","Re-prepare statements after ALTER/DROP operations","Use a query builder that validates against fetched TableMetadata"],"tags":["cassandra","cql","column"],"backgroundTag":"invalid-argument-value","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"}