apache/cassandra · error · InvalidRequestException
Some partition key parts are missing
Error message
Some partition key parts are missing: %s
What it means
For single-partition (non-range) statement types, every partition key component must be restricted with EQ or IN. When some partition key columns are unrestricted, processPartitionKeyRestrictions throws this error listing the missing components.
Solutions
- Restrict all partition key columns: WHERE pk1 = ... AND pk2 = ...
- Use the token() function with ALLOW FILTERING for a range over the full partition key
- Use a partition-key IN list supplying full tuples: WHERE (pk1, pk2) IN ((a,b),(c,d))
- Restructure the table so the partition key matches the query access pattern
Example fix
// before SELECT * FROM sensor_data WHERE sensor_id = 's1'; -- partition key is (sensor_id, date) // after SELECT * FROM sensor_data WHERE sensor_id = 's1' AND date = '2026-09-10';
Defensive patterns
Strategy: validation
Validate before calling
// Given table metadata, assert every partition key column is present in the WHERE clause
List<String> missing = table.getPartitionKeyColumns().stream()
.map(ColumnMetadata::getName)
.filter(pk -> !whereColumns.contains(pk))
.collect(Collectors.toList());
if (!missing.isEmpty()) throw new IllegalArgumentException("Missing partition key parts: " + missing); Prevention
- Read the table's PRIMARY KEY definition before writing queries
- Build queries from table metadata, not from memory
- Re-review queries whenever the partition key definition changes
When it happens
Trigger: SELECT * FROM t WHERE pk_col1 = 'a' on a composite partition key ((pk_col1, pk_col2)) without restricting pk_col2; INSERT/DELETE/SELECT on one partition key part only.
Common situations: Composite partition keys introduced after queries were written; forgetting one component of a two-column partition key; ORM-generated queries not filling all key parts.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- allowFilteringMessage(state)
- Cannot add new field
- Cannot create secondary index on the only partition key…
- Key length of is longer than maximum of
- Key may not be empty
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/3a1f46b091c1ce14.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java:571
throw new InvalidRequestException("ANN ordering does not support any other ordering");
Ordering annOrdering = annOrderings.get(0);
if (annOrdering.direction != Ordering.Direction.ASC)
throw new InvalidRequestException("Descending ANN ordering is not supported");
SingleRestriction restriction = annOrdering.expression.toRestriction();
return restrictionSet.addRestriction(restriction);
}
return restrictionSet;
}
private void processPartitionKeyRestrictions(ClientState state, boolean hasQueriableIndex, boolean allowFiltering, boolean forView)
{
if (!type.allowPartitionKeyRanges())
{
checkFalse(partitionKeyRestrictions.isOnToken(),
"The token function cannot be used in WHERE clauses for %s statements", type);
if (partitionKeyRestrictions.hasUnrestrictedPartitionKeyComponents())
throw invalidRequest("Some partition key parts are missing: %s",
Joiner.on(", ").join(getPartitionKeyUnrestrictedComponents()));
// slice query
checkFalse(partitionKeyRestrictions.hasSlice(),
"Only EQ and IN relation are supported on the partition key (unless you use the token() function)"
+ " for %s statements", type);
}
else
{
// If there are no partition restrictions or there's only token restriction, we have to set a key range
if (partitionKeyRestrictions.isOnToken())
isKeyRange = true;
if (partitionKeyRestrictions.isEmpty() && partitionKeyRestrictions.hasUnrestrictedPartitionKeyComponents())
{
isKeyRange = true;
usesSecondaryIndexing = hasQueriableIndex;
}View on GitHub (pinned to 88fd0f6a0e)