{"record":{"id":"05d144c171d94e65","repo":"apache/cassandra","slug":"partition-key-columns-are-not-yet-supported-by-sas","errorCode":null,"errorMessage":"partition key columns are not yet supported by SASI","messagePattern":"partition key columns are not yet supported by SASI","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sasi/SASIIndex.java","lineNumber":171,"sourceCode":"     */\n    public static Map<String, String> validateOptions(Map<String, String> options, TableMetadata metadata)\n    {\n        if (!(metadata.partitioner instanceof Murmur3Partitioner))\n            throw new ConfigurationException(\"SASI only supports Murmur3Partitioner.\");\n\n        String targetColumn = options.get(\"target\");\n        if (targetColumn == null)\n            throw new ConfigurationException(\"unknown target column\");\n\n        Pair<ColumnMetadata, IndexTarget.Type> target = TargetParser.parse(metadata, targetColumn);\n        if (target == null)\n            throw new ConfigurationException(\"failed to retrieve target column for: \" + targetColumn);\n\n        if (target.left.isComplex())\n            throw new ConfigurationException(\"complex columns are not yet supported by SASI\");\n\n        if (target.left.isPartitionKey())\n            throw new ConfigurationException(\"partition key columns are not yet supported by SASI\");\n\n        IndexMode.validateAnalyzer(options, target.left);\n\n        IndexMode mode = IndexMode.getMode(target.left, options);\n        if (mode.mode == Mode.SPARSE)\n        {\n            if (mode.isLiteral)\n                throw new ConfigurationException(\"SPARSE mode is only supported on non-literal columns.\");\n\n            if (mode.isAnalyzed)\n                throw new ConfigurationException(\"SPARSE mode doesn't support analyzers.\");\n        }\n\n        return Collections.emptyMap();\n    }\n\n    @Override\n    public void register(IndexRegistry registry)","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sasi/SASIIndex.java#L153-L189","documentation":"SASI refuses partition key columns as index targets. The partition key is already stored in the SSTable key and token layout, so indexing it provides no benefit; validateOptions checks target.left.isPartitionKey() and throws this ConfigurationException.","triggerScenarios":"Creating a SASI index whose 'target' option resolves to a column that is part of the table's PRIMARY KEY partition key (the first key column(s)).","commonSituations":"Script-generated indexes applied to every column of a table; developers trying to speed up partition-key lookups with SASI without realizing partition keys are directly queryable.","solutions":["Remove the index creation on the partition key column; query by partition key directly instead.","If fuzzy matching on a key-like column is needed, store the value in a duplicate non-key column and index that with SASI.","Restrict automated index generation to non-key columns."],"exampleFix":"// before (user_id is the partition key)\nCREATE CUSTOM INDEX ON users (user_id) USING 'org.apache.cassandra.index.sasi.SASIIndex';\n// after: query by the partition key directly, or index a copy\nCREATE CUSTOM INDEX ON users (user_id_text) USING 'org.apache.cassandra.index.sasi.SASIIndex'\n  WITH OPTIONS = {'target': 'user_id_text', 'mode': 'PREFIX'};","handlingStrategy":"validation","validationCode":"// skip partition key columns when auto-generating indexes\nColumnMetadata col = tableMetadata.getColumn(targetName);\nif (col.isPartitionKey()) throw new IllegalArgumentException(\"Do not index partition key column \" + targetName);","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(createIndexStmt);\n} catch (InvalidQueryException e) {\n    if (e.getMessage().contains(\"partition key columns are not yet supported\")) { /* skip or duplicate column */ }\n}","preventionTips":["Filter partition key and clustering key columns out of index-generation lists.","Remember partition key lookups need no secondary index."],"tags":["sasi","index-configuration","partition-key","cassandra"],"backgroundTag":"unsupported-config-value","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"}