{"record":{"id":"1cba119fd637bf47","repo":"apache/cassandra","slug":"unsupported-relation-s","errorCode":null,"errorMessage":"Unsupported '!=' relation: %s","messagePattern":"Unsupported '!=' relation: (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Relation.java","lineNumber":199,"sourceCode":"    public boolean onToken()\n    {\n        return rawExpressions.kind() == ColumnsExpression.Kind.TOKEN;\n    }\n\n    /**\n     * Converts this <code>Relation</code> into a <code>Restriction</code>.\n     *\n     * @param table the table metadata\n     * @param boundNames the variables specification where to collect the bind variables\n     * @return the <code>Restriction</code> corresponding to this <code>Relation</code>\n     * @throws InvalidRequestException if this <code>Relation</code> is not valid\n     */\n    public SingleRestriction toRestriction(TableMetadata table, VariableSpecifications boundNames, Object owner, boolean allowFiltering)\n    {\n        ColumnsExpression columnsExpression = rawExpressions.prepare(table);\n\n        if (operator == Operator.NEQ && columnsExpression.kind() == ColumnsExpression.Kind.TOKEN)\n            throw invalidRequest(\"Unsupported '!=' relation: %s\", this);\n\n        // TODO support restrictions on list elements as we do in conditions, then we can probably move below validations\n        //  to ElementExpression prepare/validateColumns\n        if (columnsExpression.isMapElementExpression())\n        {\n            ColumnMetadata column = columnsExpression.firstColumn();\n            AbstractType<?> baseType = column.type.unwrap();\n            checkFalse(baseType instanceof ListType, \"Indexes on list entries (%s[index] = value) are not supported.\", column.name);\n            checkTrue(baseType instanceof MapType, \"Column %s cannot be used as a map\", column.name);\n\n            if (column.isClusteringColumn() && baseType.isCollection() && !column.type.isMultiCell())\n                throw invalidRequest(FROZEN_MAP_ENTRY_PREDICATES_NOT_SUPPORTED, column.name);\n\n            columnsExpression.collectMarkerSpecification(boundNames, owner);\n        }\n\n        operator.validateFor(columnsExpression);\n","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Relation.java#L181-L217","documentation":"Relation.toRestriction rejects the != operator used with a token() relation: NEQ on token is not supported because it cannot be evaluated against the partitioner's ring during restriction conversion. InvalidRequestException at query preparation.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/Relation.java:199 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the token(...) != value relation.","Use token() with equality or range operators, or filter on partition key columns directly if ALLOW FILTERING semantics apply."],"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"}