{"record":{"id":"8ddc77f608ae6e39","repo":"apache/cassandra","slug":"it-s-not-possible-to-use-all-the-specified-include","errorCode":null,"errorMessage":"It's not possible to use all the specified included indexes with this query.","messagePattern":"It's not possible to use all the specified included indexes with this query\\.","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/filter/IndexHints.java","lineNumber":320,"sourceCode":"\n        return new IndexHints(included, excluded);\n    }\n\n    /**\n     * Validates these index hints for the specified index query plan, to verify that all the included indexes can be\n     * selected. This might happen if the query doesn't have expressions for each of the included indexes, or if it has\n     * them but the index implementation hasn't been able to use them for whatever reason.\n     *\n     * @param queryPlan the index query plan, which should have been built accordingly to these hints\n     */\n    public void validate(@Nullable Index.QueryPlan queryPlan)\n    {\n        if (queryPlan == null)\n        {\n            if (included.isEmpty())\n                return;\n            else\n                throw new InvalidRequestException(NON_INCLUDABLE_INDEXES_ERROR);\n        }\n\n        for (IndexMetadata indexMetadata : included)\n        {\n            boolean found = false;\n            for (Index i : queryPlan.getIndexes())\n            {\n                if (i.getIndexMetadata().equals(indexMetadata))\n                {\n                    found = true;\n                    break;\n                }\n            }\n            if (!found)\n                throw new InvalidRequestException(NON_INCLUDABLE_INDEXES_ERROR);\n        }\n\n        // excluded indexes should never be included because the query plans are built from a filtered list","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/filter/IndexHints.java#L302-L338","documentation":"InvalidRequestException thrown by IndexHints.validate when index hints specify included indexes but there is no query plan, or the request cannot be checked against one. Without a plan there is no way to prove the included indexes are usable, so Cassandra rejects the request up front.","triggerScenarios":"Executing a SELECT with INCLUDE INDEXES hints on a query that produced a null query plan in validate(), or hints supplied where index selection never runs.","commonSituations":"Client drivers or prepared-statement paths attaching included-index hints to queries that bypass index planning; queries against tables where hints are meaningless.","solutions":["Remove the included index hints from the query","Ensure the query is one that goes through index planning (has a query plan)","Verify the hinted indexes exist on the table and are queryable"],"exampleFix":"// before\nSELECT * FROM t WHERE a = 1; -- client attaches INCLUDE INDEXES with no query plan\n// after\nSELECT * FROM t WHERE a = 1 AND expr(t_index, 'a eq 1'); -- use a plan-backed indexed query","handlingStrategy":"validation","validationCode":"if (hints != null && hints.included != null && queryPlan == null) throw new IllegalArgumentException(\"Included index hints require a query plan\");","typeGuard":null,"tryCatchPattern":"try { session.execute(stmt); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"included indexes\")) stmt = stripIndexHints(stmt); }","preventionTips":["Attach included hints only to queries that go through index planning","Validate hints client-side against the table's existing indexes","Strip hints in fallback paths that bypass planning"],"tags":["cassandra","index-hints","cql"],"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"}