{"record":{"id":"e4824b1accdb964f","repo":"apache/cassandra","slug":"cannot-filter-this-table-by-partial-partition-key","errorCode":null,"errorMessage":"Cannot filter this table by partial partition key","messagePattern":"Cannot filter this table by partial partition key","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java","lineNumber":1546,"sourceCode":"                if (filterTxnId.min != null || filterTxnId.max != null || minCommandStoreId >= 0 || maxCommandStoreId < Integer.MAX_VALUE)\n                {\n                    min = new JournalKey(filterTxnId.min == null ? TxnId.NONE : filterTxnId.min, JournalKey.Type.COMMAND_DIFF, Math.max(0, minCommandStoreId));\n                    max = new JournalKey(filterTxnId.max == null ? TxnId.MAX.withoutNonIdentityFlags() : filterTxnId.max, JournalKey.Type.COMMAND_DIFF, maxCommandStoreId);\n                }\n            }\n\n            accord.journal().forEach(key -> collect(collector, accord, key), min, max, true, 0);\n        }\n\n        abstract void collect(PartitionsCollector collector, AccordService accord, JournalKey key);\n\n        private static JournalKey toJournalKey(PartitionPosition position)\n        {\n            if (position.isMinimum())\n                return null;\n\n            if (!(position instanceof DecoratedKey))\n                throw new InvalidRequestException(\"Cannot filter this table by partial partition key\");\n\n            ByteBuffer[] keys = PK.split(((DecoratedKey) position).getKey());\n            return new JournalKey(TxnId.parse(UTF8Type.instance.compose(keys[1])), JournalKey.Type.COMMAND_DIFF, Int32Type.instance.compose(keys[0]));\n        }\n    }\n\n    // TODO (desired): don't report null as \"null\"\n    public static abstract class AbstractTxnTable extends AbstractJournalTable\n    {\n        private AbstractTxnTable(String tableName)\n        {\n            super(parse(VIRTUAL_ACCORD_DEBUG, tableName,\n                        \"Accord per-CommandStore Transaction State\",\n                        \"CREATE TABLE %s (\\n\" +\n                        \"  command_store_id int,\\n\" +\n                        \"  txn_id 'TxnIdUtf8Type',\\n\" +\n                        \"  ballot_accepted text,\\n\" +\n                        \"  ballot_promised text,\\n\" +","sourceCodeStart":1528,"sourceCodeEnd":1564,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java#L1528-L1564","documentation":"The accord_debug journal table can only be filtered by a full (decorated) partition key. When the query's partition position is the minimum bound (partial/range filtering) the helper returns null, and if the position is a non-decorated key boundary (partial key), toJournalKey throws InvalidRequestException.","triggerScenarios":"Querying the journal table with a token-range or partial partition-key filter (e.g. WHERE key > 'x' on part of a composite key, or TokenAware ranges) instead of an exact equality on the complete partition key.","commonSituations":"Browsing the journal table with range predicates from cqlsh; building tooling that slices the journal by txn id prefix; misunderstanding the composite key structure (id, txn_id).","solutions":["Filter with exact equality on the full partition key (both composite key components: id and txn_id).","Drop range/bounds predicates and iterate candidate keys client-side instead.","Construct the key so position is a DecoratedKey, not a minimum/boundary token.","Use the dedicated commands_for_key style tables for key-based lookups where applicable."],"exampleFix":"// before\nsession.execute(\"SELECT * FROM system_views.accord_debug_journal WHERE key > 'some-prefix'\");\n// after\nsession.execute(\"SELECT * FROM system_views.accord_debug_journal WHERE key = 'full-partition-key-value'\");","handlingStrategy":"validation","validationCode":"if (!whereClause.matches(\"(?s).*key\\s*=\\s*'[^']+'\\s*\")) throw new IllegalArgumentException(\"journal table requires exact equality on the full partition key\");","typeGuard":null,"tryCatchPattern":"try { session.execute(query); } catch (com.datastax.driver.core.exceptions.InvalidQueryException e) { if (e.getMessage().contains(\"partial partition key\")) { /* replace range predicate with exact key equality */ } else throw e; }","preventionTips":["Filter journal/debug tables only with full partition-key equality","Avoid range or token predicates on accord_debug tables","Iterate candidate keys client-side instead of server-side ranges"],"tags":["virtual-table","partition-key","accord","invalid-request","cassandra"],"backgroundTag":"invalid-query-parameter","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"}