apache/cassandra · error · InvalidRequestException
Duplicate column ' ' in CLUSTERING ORDER BY clause for view
Error message
Duplicate column '%s' in CLUSTERING ORDER BY clause for view '%s'
What it means
Guard in CreateViewStatement.RawStatement.extendClusteringOrder() (parser-side builder): CLUSTERING ORDER BY names the same column twice. clusteringOrder is a map keyed by column identifier, and put() returning a previous value signals the duplicate; the statement is rejected with InvalidRequestException before schema application.
Solutions
- List each column at most once in the CLUSTERING ORDER BY clause; remove the redundant entry, since unspecified clustering columns default to ascending order.
Example fix
// before WITH CLUSTERING ORDER BY (ts ASC, ts DESC) // after WITH CLUSTERING ORDER BY (ts ASC)
Defensive patterns
Strategy: validation
Validate before calling
const cols = order.map(o => o.column); if (new Set(cols).size !== cols.length) throw new Error('Duplicate column in CLUSTERING ORDER BY'); Try / catch
try { session.execute(ddl); } catch (e) { if (e instanceof InvalidQueryError && /Duplicate column/.test(e.message)) { /* deduplicate ORDER BY list */ } else throw e; } Prevention
- Deduplicate clustering columns when programmatically assembling ORDER BY clauses
- Review generated DDL output before execution
When it happens
Trigger: CREATE MATERIALIZED VIEW ... WITH CLUSTERING ORDER BY (col ASC, col DESC) or any duplicate column listed twice in the ORDER BY clause.
Common situations: Programmatic view builders appending the same column twice; hand-written DDL repeating a column with different directions; generated DDL merging two order specs.
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
- Duplicate column ' ' in PRIMARY KEY clause for materialized…
- ACCESS TO DATACENTERS operations not supported by…
- Bind variables are not allowed in CREATE MATERIALIZED VIEW…
- Can only select columns by name when defining a…
- Cannot alter gc_grace_seconds of a materialized view to 0…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/feaba3f5fb41f886.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateViewStatement.java:492
attrs,
ifNotExists);
}
public void setPartitionKeyColumns(List<ColumnIdentifier> columns)
{
partitionKeyColumns = columns;
}
public void markClusteringColumn(ColumnIdentifier column)
{
clusteringColumns.add(column);
}
public void extendClusteringOrder(ColumnIdentifier column, boolean ascending)
{
if (null != clusteringOrder.put(column, ascending))
throw ire("Duplicate column '%s' in CLUSTERING ORDER BY clause for view '%s'", column, viewName);
}
}
}
View on GitHub (pinned to 88fd0f6a0e)