{"record":{"id":"d71114926434a6ea","repo":"apache/cassandra","slug":"the-token-function-arguments-must-be-in-the-partit","errorCode":null,"errorMessage":"The token function arguments must be in the partition key order: %s","messagePattern":"The token function arguments must be in the partition key order: (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/ColumnsExpression.java","lineNumber":150,"sourceCode":"         * Token expression (e.g. {@code token(columnA, columnB)})\n         */\n        TOKEN\n        {\n            @Override\n            protected void validateColumns(TableMetadata table, List<ColumnMetadata> columns)\n            {\n                if (columns.equals(table.partitionKeyColumns()))\n                    return;\n\n                // If the columns do not match the partition key columns, let's try to narrow down the problem\n                checkTrue(new HashSet<>(columns).containsAll(table.partitionKeyColumns()),\n                        \"The token() function must be applied to all partition key components or none of them\");\n\n                checkContainsNoDuplicates(columns, \"The token() function contains duplicate partition key components\");\n\n                checkContainsOnly(columns, table.partitionKeyColumns(), \"The token() function must contains only partition key components\");\n\n                throw invalidRequest(\"The token function arguments must be in the partition key order: %s\",\n                                     Joiner.on(\", \").join(ColumnMetadata.toIdentifiers(table.partitionKeyColumns())));\n            }\n\n            @Override\n            AbstractType<?> type(TableMetadata table, List<ColumnMetadata> columns, ElementExpression element)\n            {\n                return table.partitioner.getTokenValidator();\n            }\n\n            @Override\n            String toCQLString(List<String> columns, String element)\n            {\n                StringBuilder builder = new StringBuilder();\n                builder.append(\"token(\");\n                Joiner.on(\", \").appendTo(builder, columns);\n                return builder.append(')').toString();\n            }\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/ColumnsExpression.java#L132-L168","documentation":"Validation in ColumnsExpression.TOKEN.validateColumns: the columns given to token() were not exactly the partition key columns in partition key order. The checkTrue distinguishes a wrong order (this message) from missing partition key columns (a different message).","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/ColumnsExpression.java:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reorder the token() arguments to match the partition key column order defined in the table schema."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}