apache/cassandra · error · InvalidRequestException
Duplicate column ' ' declaration for table
Error message
Duplicate column '%s' declaration for table '%s'
What it means
The same column name appears more than once in the CREATE TABLE column list. The raw builder stores columns in a map keyed by ColumnIdentifier; if put() returns a previous value, the column was declared twice and the statement is rejected.
Solutions
- Remove the duplicate column declaration, keeping only one type per name
- Rename one of the colliding columns
- If identifiers are quoted, ensure casing does not collapse two names into the same identifier
Example fix
// before CREATE TABLE t (a int, a text, PRIMARY KEY (a)); // after CREATE TABLE t (a int, b text, PRIMARY KEY (a));
Defensive patterns
Strategy: validation
Validate before calling
const names = cols.map(c => c.name.toLowerCase());
const dup = names.find((n, i) => names.indexOf(n) !== i);
if (dup) throw new Error(`Duplicate column: ${dup}`); Try / catch
try { session.execute(ddl); } catch (e) { if (/Duplicate column/.test(e.message)) { /* de-duplicate the column list and retry */ } else throw e; } Prevention
- De-duplicate column names (case-insensitively) before generating DDL
- Avoid concatenating column lists from multiple schema fragments
- Be careful with quoted identifiers changing casing
When it happens
Trigger: CREATE TABLE t (a int, a text); — the second addColumn call for an already-declared identifier throws.
Common situations: Copy-pasted column definitions; generated DDL concatenating column lists from multiple sources; case-insensitive collisions if quoting differs (e.g. A and "A" resolve to the same identifier).
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- ACCESS TO DATACENTERS operations not supported by…
- Aggregate ' ' already exists
- Argument ' ' cannot be frozen; remove frozen<> modifier from
- Can not alter a keyspace to use MetaReplicationStrategy
- Cannot add a column ' ' of type , incompatible with…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/31ec95f05a9a7190.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java:626
name.setKeyspace(keyspace, true);
return this;
}
public Raw table(String table)
{
name.setName(table, true);
return this;
}
public String table()
{
return name.getName();
}
public void addColumn(ColumnIdentifier column, CQL3Type.Raw type, boolean isStatic, boolean isNotNull, ColumnMask.Raw mask, ColumnConstraints.Raw constraints)
{
if (null != rawColumns.put(column, new ColumnProperties.Raw(type, mask)))
throw ire("Duplicate column '%s' declaration for table '%s'", column, name);
if (isStatic)
staticColumns.add(column);
ColumnConstraints preparedConstraints = constraints == null ? ColumnConstraints.NO_OP : constraints.prepare(column);
if (isNotNull)
{
if (preparedConstraints.containsNotNullConstraint())
throw ire("Duplicate definition of NOT NULL constraint");
List<ColumnConstraint<?>> checkConstraints = new ArrayList<>(preparedConstraints.getConstraints());
checkConstraints.add(new UnaryFunctionColumnConstraint(new NotNullConstraint()));
preparedConstraints = new ColumnConstraints(checkConstraints);
preparedConstraints.setColumnName(column);
}
columnConstraints.put(column, preparedConstraints);View on GitHub (pinned to 88fd0f6a0e)