{"record":{"id":"898e6616286b896c","repo":"apache/cassandra","slug":"column-s-doesn-t-exist","errorCode":null,"errorMessage":"Column '%s' doesn't exist","messagePattern":"Column '(.+?)' doesn't exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java","lineNumber":862,"sourceCode":"            if (column != null)\n            {\n                ColumnConstraints oldConstraints = column.getColumnConstraints();\n                ColumnConstraints newConstraints = constraints == null ? ColumnConstraints.NO_OP : constraints.prepare(columnName);\n                if (Objects.equals(oldConstraints, newConstraints))\n                    return keyspace;\n                newConstraints.validate(column);\n                TableMetadata.Builder tableBuilder = table.unbuild().epoch(epoch);\n                tableBuilder.alterColumnConstraints(columnName, newConstraints);\n\n                TableMetadata newTable = tableBuilder.build();\n                newTable.validate();\n\n                return keyspace.withSwapped(keyspace.tables.withSwapped(newTable));\n            }\n            else\n            {\n                if (!ifColumnExists)\n                    throw ire(\"Column '%s' doesn't exist\", columnName);\n            }\n            return keyspace;\n        }\n\n        @Override\n        public boolean compatibleWith(ClusterMetadata metadata)\n        {\n            return metadata.directory.commonSerializationVersion.isAtLeast(Version.V5);\n        }\n    }\n\n    public static final class Raw extends CQLStatement.Raw\n    {\n        private enum Kind\n        {\n            ALTER_COLUMN,\n            MASK_COLUMN,\n            ADD_COLUMNS,","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java#L844-L880","documentation":"Thrown by ALTER TABLE when the column named in the statement does not exist on the target table. Cassandra refuses the schema change unless the IF EXISTS clause for columns is supplied, in which case it becomes a silent no-op. It prevents executing schema alterations against a column identifier that does not match the table schema.","triggerScenarios":"Running `ALTER TABLE ks.t DROP col`, `ALTER TABLE ks.t ALTER col TYPE ...` or similar with a columnName that is absent from the table's schema, without `ifColumnExists` set (i.e. no `IF EXISTS` column clause in the CQL).","commonSituations":"Typos in the column name; case-sensitivity mistakes (unquoted identifiers are lowercased, quoted ones are not); running migrations against an environment where the column was never added or already dropped; concurrent migrations racing to drop the same column.","solutions":["Verify the column exists with `DESCRIBE TABLE ks.t;` or a system_schema.columns query and fix the spelling/casing","Add `IF EXISTS` to the statement (e.g. `ALTER TABLE ks.t DROP \"col\" IF EXISTS;`) if a no-op is acceptable","Check you are connected to the intended keyspace/cluster and that prior migrations that add the column actually ran"],"exampleFix":"// before\nALTER TABLE users DROP old_email;\n// after\nALTER TABLE users DROP old_email IF EXISTS;","handlingStrategy":"validation","validationCode":"boolean exists = session.execute(\"SELECT column_name FROM system_schema.columns WHERE keyspace_name=? AND table_name=? AND column_name=?\", ks, table, col).iterator().hasNext();\nif (!exists) throw new IllegalStateException(col + \" does not exist on \" + ks + \".\" + table);","typeGuard":"boolean columnExists(Session s, String ks, String table, String col) {\n    return s.execute(\"SELECT column_name FROM system_schema.columns WHERE keyspace_name=? AND table_name=? AND column_name=?\", ks, table, col).iterator().hasNext();\n}","tryCatchPattern":"try { session.execute(alterStmt); }\ncatch (InvalidQueryException e) {\n    if (e.getMessage().startsWith(\"Column \") && e.getMessage().endsWith(\"doesn't exist\")) {\n        // log and skip or re-sync schema\n    } else throw e;\n}","preventionTips":["Check system_schema.columns (or DESCRIBE TABLE) before altering","Use IF EXISTS when a no-op is acceptable","Keep migrations idempotent and ordered","Watch identifier case-sensitivity: quote names only when they were created quoted"],"tags":["cql","schema","alter-table"],"backgroundTag":"schema-validation-failed","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"}