apache/cassandra · error · InvalidRequestException
Column ' ' doesn't exist in table ' .
Error message
Column '%s' doesn't exist in table '%s.%s'
What it means
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.
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
Example fix
// before COMMENT ON COLUMN ks.users.Email IS 'user email'; // after COMMENT ON COLUMN ks.users."Email" IS 'user email'; -- or use correct lowercase name email
Defensive patterns
Strategy: validation
Validate before calling
// Check the column exists first
const rows = await session.execute(
"SELECT column_name FROM system_schema.columns WHERE keyspace_name=? AND table_name=? AND column_name=?",
[keyspace, table, columnName]);
if (rows.rows.length === 0) throw new Error(`Column ${columnName} not found in ${keyspace}.${table}`); Type guard
null
Try / catch
try {
session.execute(`COMMENT ON COLUMN ${ks}.${t}.${c} IS '...'`);
} catch (e) {
if (/Column .* doesn't exist/.test(e.message)) {
// run column-adding migration first, then retry
} else throw e;
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: Documentation-generation scripts referencing outdated schemas; case sensitivity issues for non-lowercase identifiers without quotes; running comments migrations before the column-adding migration.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Column with name ' ' doesn't exist on table
- ACCESS TO DATACENTERS operations not supported by…
- aggregate functions cannot be used as arguments of…
- allowFilteringMessage(state)
- Altering column types is no longer supported
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/0759e0d855b29e28.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CommentOnColumnStatement.java:81
this.tableName = tableName;
this.columnName = columnName;
}
@Override
public boolean compatibleWith(ClusterMetadata metadata)
{
return metadata.directory.commonSerializationVersion.isAtLeast(Version.V8);
}
@Override
public Keyspaces apply(ClusterMetadata metadata)
{
Keyspaces schema = metadata.schema.getKeyspaces();
TableMetadata table = validateAndGetTable(schema, tableName);
ColumnMetadata columnMetadata = table.getColumn(columnName);
if (null == columnMetadata)
throw ire("Column '%s' doesn't exist in table '%s.%s'", columnName, keyspaceName, tableName);
KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
TableMetadata newTable = table.unbuild().alterColumnComment(columnName, effectiveDescription()).build();
KeyspaceMetadata newKeyspace = keyspace.withSwapped(keyspace.tables.withSwapped(newTable));
return schema.withAddedOrUpdated(newKeyspace);
}
@Override
SchemaChange schemaChangeEvent(KeyspacesDiff diff)
{
return new SchemaChange(Change.UPDATED, Target.TABLE, keyspaceName, tableName);
}
@Override
public void authorize(ClientState client)
{
client.ensureTablePermission(keyspaceName, tableName, Permission.ALTER);View on GitHub (pinned to 88fd0f6a0e)