apache/cassandra · error · InvalidRequestException

Column with name ' ' doesn't exist on table

Error message

Column with name '%s' doesn't exist on table '%s'

What it means

Thrown by ALTER TABLE ... DROP/RENAME/ALTER column operations when the named column does not exist on the table and IF (the column) EXISTS was not specified. The statement is rejected with an InvalidRequestException naming both column and table.

Solutions

  1. Check the column exists: SELECT column_name FROM system_schema.columns WHERE keyspace_name=? AND table_name=?
  2. Use IF EXISTS on the column: ALTER TABLE ks.tbl DROP IF EXISTS col
  3. Fix the column name spelling/case or quote it if mixed-case

Example fix

// before
session.execute("ALTER TABLE my_app.events DROP descripton text");
// after
session.execute("ALTER TABLE my_app.events DROP IF EXISTS description");
Defensive patterns

Strategy: validation

Validate before calling

ResultSet rs = session.execute("SELECT column_name FROM system_schema.columns WHERE keyspace_name=? AND table_name=?", ks, table);
boolean exists = rs.all().stream().anyMatch(r -> r.getString("column_name").equals(column.toLowerCase()));
if (!exists) throw new IllegalStateException("Column " + column + " missing on " + ks + "." + table);

Try / catch

try {
    session.execute(alter);
} catch (InvalidRequestException e) {
    if (e.getMessage().contains("doesn't exist on table"))
        log.warn("Column already absent; treating DROP as no-op: {}", alter);
    else throw e;
}

Prevention

When it happens

Trigger: 'ALTER TABLE ks.tbl DROP col' (or RENAME/ALTER col) where table.getColumn(columnName) returns null and ifColumnExists is false

Common situations: Migration scripts re-run after the column was already dropped; column-name typos or case sensitivity (unquoted names become lowercase); schema drift between environments (column exists in staging but not prod).

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/e196ada482352145. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java:237

            if (rawMask != null)
                ColumnMask.ensureEnabled();
        }

        @Override
        public boolean compatibleWith(ClusterMetadata metadata)
        {
            return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
        }

        @Override
        public KeyspaceMetadata apply(Epoch epoch, KeyspaceMetadata keyspace, TableMetadata table, ClusterMetadata metadata)
        {
            ColumnMetadata column = table.getColumn(columnName);

            if (column == null)
            {
                if (!ifColumnExists)
                    throw ire("Column with name '%s' doesn't exist on table '%s'", columnName, tableName);

                return keyspace;
            }

            // add all user functions to be able to give a good error message to the user if the alter references
            // a function from another keyspace
            UserFunctions.Builder ufBuilder = UserFunctions.builder();
            for (KeyspaceMetadata ksm : metadata.schema.getKeyspaces())
                ufBuilder.add(ksm.userFunctions);

            ColumnMask oldMask = table.getColumn(columnName).getMask();
            ColumnMask newMask = rawMask == null ? null : rawMask.prepare(keyspace.name, table.name, columnName, column.type, ufBuilder.build());

            if (Objects.equals(oldMask, newMask))
                return keyspace;

            TableMetadata.Builder tableBuilder = table.unbuild().epoch(epoch);
            tableBuilder.alterColumnMask(columnName, newMask);

View on GitHub (pinned to 88fd0f6a0e)