{"record":{"id":"d71b63bbd9d96e0a","repo":"apache/cassandra","slug":"invalid-operator","errorCode":null,"errorMessage":"Invalid operator","messagePattern":"Invalid operator","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sai/plan/Operation.java","lineNumber":287,"sourceCode":"        IndexTarget.Type indexTargetType = IndexTarget.Type.SIMPLE;\n        if (type.isCollection() && type.isMultiCell())\n        {\n            CollectionType<?> collection = ((CollectionType<?>) type);\n            if (collection.kind == CollectionType.Kind.MAP)\n            {\n                switch (expression.operator())\n                {\n                    case EQ:\n                        indexTargetType = IndexTarget.Type.KEYS_AND_VALUES;\n                        break;\n                    case CONTAINS:\n                        indexTargetType = IndexTarget.Type.VALUES;\n                        break;\n                    case CONTAINS_KEY:\n                        indexTargetType = IndexTarget.Type.KEYS;\n                        break;\n                    default:\n                        throw new InvalidRequestException(\"Invalid operator\");\n                }\n            }\n        }\n        return indexTargetType;\n    }\n\n    private static int getPriority(Operator op)\n    {\n        switch (op)\n        {\n            case EQ:\n            case CONTAINS:\n            case CONTAINS_KEY:\n                return 5;\n\n            case GTE:\n            case GT:\n                return 3;","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sai/plan/Operation.java#L269-L305","documentation":"Operation.determineIndexTargetType maps a relation's operator to an IndexTarget.Type for SAI index targeting. If the operator falls through all known cases (an operator that cannot be answered by the selected index type), it throws InvalidRequestException(\"Invalid operator\").","triggerScenarios":"Using a CQL relation operator that SAI's target-type mapping does not handle for the given index kind — e.g. an operator like LIKE/CONTAINS applied where the switch has no matching case, after `break`-less fall-through reaches the default branch of the operator-to-IndexTarget.Type switch.","commonSituations":"Typing an operator that the index doesn't support (e.g. CONTAINS on a non-collection target, SIMILARITY/ANN operator mixed into non-vector expressions); version mismatch where a new operator isn't yet mapped for SAI.","solutions":["Use an operator supported by SAI for that column type (EQ, LT/LTE/GT/GTE, CONTAINS/CONTAINS KEY on collections, ANN on vectors)","Check the CREATE INDEX target type matches the query operator semantics","Upgrade Cassandra if the operator should be supported in your version"],"exampleFix":"// before\nSELECT * FROM t WHERE vec ANN OF [1,2] AND description CONTAINS 'x' AND id != 5; // unsupported operator in SAI targeting\n// after\nSELECT * FROM t WHERE vec ANN OF [1,2] AND description CONTAINS 'x' AND (id > 5 OR id < 5);","handlingStrategy":"validation","validationCode":"// Only use operators SAI supports for the target type:\n// scalar: =, <, <=, >, >= ; collection: CONTAINS / CONTAINS KEY ; vector: ANN OF","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check operator-to-index-type compatibility before querying","Avoid mixing operators (e.g. !=, custom ops) into SAI-targeted predicates","Keep Cassandra version current for newly supported operators"],"tags":["sai","cql","query-planning","invalid-request"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}