apache/cassandra · error · InvalidRequestException
Static columns are only useful (and thus allowed) if the tab
Error message
Static columns are only useful (and thus allowed) if the table has at least one clustering column
What it means
Static columns store a single value per partition, which is only meaningful when the table has clustering columns to vary within a partition. If the table has no clustering columns, all rows are one-per-partition anyway, so static columns add nothing — Cassandra rejects their declaration at CREATE TABLE time.
Source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java:368
{
if (clusteringOrder.containsKey(c))
throw ire("The order of columns in the CLUSTERING ORDER directive must match that of the clustering columns (%s must appear before %s)", c, id);
else
throw ire("Missing CLUSTERING ORDER for column %s", c);
}
++n;
}
// For COMPACT STORAGE, we reject any "feature" that we wouldn't be able to translate back to thrift.
if (useCompactStorage)
{
validateCompactTable(clusteringColumnProperties, columns);
}
else
{
// Static columns only make sense if we have at least one clustering column. Otherwise everything is static anyway
if (clusteringColumns.isEmpty() && !staticColumns.isEmpty())
throw ire("Static columns are only useful (and thus allowed) if the table has at least one clustering column");
}
/*
* Counter table validation
*/
boolean hasCounters = rawColumns.values().stream().anyMatch(c -> c.rawType.isCounter());
if (hasCounters)
{
// We've handled anything that is not a PRIMARY KEY so columns only contains NON-PK columns. So
// if it's a counter table, make sure we don't have non-counter types
if (columns.values().stream().anyMatch(t -> !t.type.isCounter()))
throw ire("Cannot mix counter and non counter columns in the same table");
if (params.defaultTimeToLive > 0)
throw ire("Cannot set %s on a table with counters", TableParams.Option.DEFAULT_TIME_TO_LIVE);
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Drop the STATIC keyword from the column definition.
- Add at least one clustering column to the PRIMARY KEY so static columns become meaningful.
Example fix
// before CREATE TABLE t (pk int, v text STATIC, PRIMARY KEY (pk)); // after CREATE TABLE t (pk int, v text, PRIMARY KEY (pk));
Defensive patterns
Strategy: validation
Validate before calling
// A table may declare STATIC columns only if it has clustering columns:
boolean hasClustering = false; // true if PRIMARY KEY has columns after the partition key
boolean hasStatic = false; // any column declared STATIC
if (hasStatic && !hasClustering) throw new IllegalArgumentException("STATIC column requires a clustering column"); Try / catch
try { session.execute(ddl); } catch (com.datastax.driver.core.exceptions.InvalidQueryException e) { if (e.getMessage().contains("Static columns are only useful")) { /* drop STATIC or add clustering */ } else throw e; } Prevention
- Only mark columns STATIC in tables with composite (partition + clustering) primary keys.
- Remember STATIC is meaningless in single-row-per-partition tables.
- Validate generated DDL with a static-column check.
When it happens
Trigger: CREATE TABLE t (pk int, v text STATIC, PRIMARY KEY (pk)) — a static column with a partition-key-only primary key.
Common situations: Copying a table definition with STATIC columns and simplifying the primary key to only the partition key; misunderstanding static column semantics in tables without clustering columns.
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
- Only clustering key columns can be defined in CLUSTERING ORD
- The order of columns in the CLUSTERING ORDER directive must
- Missing CLUSTERING ORDER for column %s
- Cannot mix counter and non counter columns in the same table
- Cannot set %s on a table with counters
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4f9fe8dfbfdb5381.
Report an issue: GitHub.