{"record":{"id":"3a1f46b091c1ce14","repo":"apache/cassandra","slug":"some-partition-key-parts-are-missing-s","errorCode":null,"errorMessage":"Some partition key parts are missing: %s","messagePattern":"Some partition key parts are missing: (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java","lineNumber":571,"sourceCode":"                throw new InvalidRequestException(\"ANN ordering does not support any other ordering\");\n            Ordering annOrdering = annOrderings.get(0);\n            if (annOrdering.direction != Ordering.Direction.ASC)\n                throw new InvalidRequestException(\"Descending ANN ordering is not supported\");\n            SingleRestriction restriction = annOrdering.expression.toRestriction();\n            return restrictionSet.addRestriction(restriction);\n        }\n        return restrictionSet;\n    }\n\n    private void processPartitionKeyRestrictions(ClientState state, boolean hasQueriableIndex, boolean allowFiltering, boolean forView)\n    {\n        if (!type.allowPartitionKeyRanges())\n        {\n            checkFalse(partitionKeyRestrictions.isOnToken(),\n                       \"The token function cannot be used in WHERE clauses for %s statements\", type);\n\n            if (partitionKeyRestrictions.hasUnrestrictedPartitionKeyComponents())\n                throw invalidRequest(\"Some partition key parts are missing: %s\",\n                                     Joiner.on(\", \").join(getPartitionKeyUnrestrictedComponents()));\n\n            // slice query\n            checkFalse(partitionKeyRestrictions.hasSlice(),\n                    \"Only EQ and IN relation are supported on the partition key (unless you use the token() function)\"\n                            + \" for %s statements\", type);\n        }\n        else\n        {\n            // If there are no partition restrictions or there's only token restriction, we have to set a key range\n            if (partitionKeyRestrictions.isOnToken())\n                isKeyRange = true;\n\n            if (partitionKeyRestrictions.isEmpty() && partitionKeyRestrictions.hasUnrestrictedPartitionKeyComponents())\n            {\n                isKeyRange = true;\n                usesSecondaryIndexing = hasQueriableIndex;\n            }","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java#L553-L589","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nSELECT * FROM sensor_data WHERE sensor_id = 's1';  -- partition key is (sensor_id, date)\n// after\nSELECT * FROM sensor_data WHERE sensor_id = 's1' AND date = '2026-09-10';","handlingStrategy":"validation","validationCode":"// Given table metadata, assert every partition key column is present in the WHERE clause\nList<String> missing = table.getPartitionKeyColumns().stream()\n    .map(ColumnMetadata::getName)\n    .filter(pk -> !whereColumns.contains(pk))\n    .collect(Collectors.toList());\nif (!missing.isEmpty()) throw new IllegalArgumentException(\"Missing partition key parts: \" + missing);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cql","cassandra","partition-key"],"backgroundTag":"missing-required-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}