{"record":{"id":"cdfa05ff10fa4c3b","repo":"apache/cassandra","slug":"unsupported-expression-during-index-query","errorCode":null,"errorMessage":"Unsupported expression during index query: ","messagePattern":"Unsupported expression during index query: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sai/disk/v1/segment/NumericIndexSegmentSearcher.java","lineNumber":96,"sourceCode":"    {\n        return treeReader.memoryUsage();\n    }\n\n    @Override\n    public KeyRangeIterator search(Expression exp, AbstractBounds<PartitionPosition> keyRange, QueryContext context) throws IOException\n    {\n        if (logger.isTraceEnabled())\n            logger.trace(index.identifier().logMessage(\"Searching on expression '{}'...\"), exp);\n\n        if (exp.getIndexOperator().isEqualityOrRange())\n        {\n            final BlockBalancedTreeReader.IntersectVisitor query = balancedTreeQueryFrom(exp, treeReader.getBytesPerValue());\n            QueryEventListener.BalancedTreeEventListener listener = MulticastQueryEventListeners.of(context, perColumnEventListener);\n            return toPrimaryKeyIterator(treeReader.intersect(query, listener, context), context);\n        }\n        else\n        {\n            throw new IllegalArgumentException(index.identifier().logMessage(\"Unsupported expression during index query: \" + exp));\n        }\n    }\n\n    @Override\n    public String toString()\n    {\n        return MoreObjects.toStringHelper(this)\n                          .add(\"index\", index)\n                          .add(\"count\", treeReader.getPointCount())\n                          .add(\"bytesPerValue\", treeReader.getBytesPerValue())\n                          .toString();\n    }\n\n    @Override\n    public void close()\n    {\n        treeReader.close();\n    }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sai/disk/v1/segment/NumericIndexSegmentSearcher.java#L78-L114","documentation":"Thrown when the segment searcher's numeric balanced-tree path receives an expression it cannot translate into a BlockBalancedTreeReader.IntersectVisitor. Only expression types the tree query builder recognizes (e.g. EQ, range comparisons, IN, LIKE prefix) are supported at this code path; anything else reaches the else branch. It wraps the message with the index identifier's log message for context.","triggerScenarios":"Executing a query whose expression `exp` is dispatched to the numeric index searcher but is not one of the supported operators, e.g. an operator added in newer code, a null/unsupported operator, or an ANN/CONTAINS expression misrouted here.","commonSituations":"Querying a numeric SAI index with a new operator before the tree query builder was extended, version skew between coordinator and node code, or internal routing bugs selecting the wrong searcher.","solutions":["Check the operator used in the query against the supported operators for numeric SAI indexes (EQ, <, <=, >, >=, IN, LIKE 'prefix%')","Rewrite the query to use a supported operator or allow filtering (ALLOW FILTERING) without the index","Ensure all nodes run the same Cassandra version so query planning and searchers agree","If a valid operator hits this, file a bug with the exact query and index type"],"exampleFix":"// before\nSELECT ... FROM t WHERE numcol CONTAINS 5;   // unsupported on numeric SAI\n// after\nSELECT ... FROM t WHERE numcol = 5;          // supported equality intersection","handlingStrategy":"validation","validationCode":"Set<Expression.Op> supported = Set.of(EQ, LT, LTE, GT, GTE, IN, LIKE_PREFIX);\nif (!supported.contains(exp.getOp()))\n    throw new IllegalArgumentException(\"Operator not supported by numeric SAI index: \" + exp.getOp());","typeGuard":"boolean isNumericIndexOperator(Expression exp) {\n    return Expression.IndexOperator.EQ.equals(exp.getIndexOperator())\n        || Expression.IndexOperator.RANGE.equals(exp.getIndexOperator());\n}","tryCatchPattern":"try {\n    return searcher.search(exp, ...);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Falling back to non-index scan: {}\", e.getMessage());\n    return fallbackScan(exp);\n}","preventionTips":["Only use operators known to be supported by numeric SAI indexes","Pin the same Cassandra version on all nodes","Test new query shapes against SAI indexes before production rollout"],"tags":["cassandra","sai","query","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}