{"record":{"id":"5bc1c706c9824cda","repo":"apache/cassandra","slug":"missing-target-column","errorCode":null,"errorMessage":"Missing target column","messagePattern":"Missing target column","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java","lineNumber":250,"sourceCode":"                unknown.put(option.getKey(), option.getValue());\n            }\n        }\n\n        if (!unknown.isEmpty())\n        {\n            return unknown;\n        }\n\n        if (ILLEGAL_PARTITIONERS.contains(metadata.partitioner.getClass()))\n        {\n            throw new InvalidRequestException(\"Storage-attached index does not support the following IPartitioner implementations: \" + ILLEGAL_PARTITIONERS);\n        }\n\n        String targetColumn = options.get(IndexTarget.TARGET_OPTION_NAME);\n\n        if (targetColumn == null)\n        {\n            throw new InvalidRequestException(\"Missing target column\");\n        }\n\n        if (targetColumn.split(\",\").length > 1)\n        {\n            throw new InvalidRequestException(\"A storage-attached index cannot be created over multiple columns: \" + targetColumn);\n        }\n\n        Pair<ColumnMetadata, IndexTarget.Type> target = TargetParser.parse(metadata, targetColumn);\n\n        if (target == null)\n        {\n            throw new InvalidRequestException(\"Failed to retrieve target column for: \" + targetColumn);\n        }\n\n        // In order to support different index targets on non-frozen map, ie. KEYS, VALUE, ENTRIES, we need to put index\n        // name as part of index file name instead of column name. We only need to check that the target is different\n        // between indexes. This will only allow indexes in the same column with a different IndexTarget.Type.\n        //","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sai/StorageAttachedIndex.java#L232-L268","documentation":"StorageAttachedIndex.validateOptions throws InvalidRequestException(\"Missing target column\") when the index options contain no 'target' entry. An SAI index must declare the column it indexes; without a target the index has nothing to build over.","triggerScenarios":"CREATE CUSTOM INDEX with USING StorageAttachedIndex but no column in the index specification, or options map constructed programmatically without the target option.","commonSituations":"Programmatic IndexMetadata construction omitting IndexTarget.TARGET_OPTION_NAME; corrupted/hand-edited schema; driver or tooling bug generating the CREATE INDEX statement.","solutions":["Specify the column: CREATE CUSTOM INDEX idx ON ks.tbl (col) USING 'StorageAttachedIndex'","If constructing IndexMetadata in code, set options with IndexTarget.TARGET_OPTION_NAME","Check generated schema statements for a missing column list"],"exampleFix":"// before\nCREATE CUSTOM INDEX idx ON ks.tbl () USING 'StorageAttachedIndex';\n// after\nCREATE CUSTOM INDEX idx ON ks.tbl (email) USING 'StorageAttachedIndex';","handlingStrategy":"validation","validationCode":"String target = indexOptions.get(\"target\");\nif (target == null || target.isBlank()) throw new IllegalArgumentException(\"SAI index requires a target column\");","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidRequestException e) { if (e.getMessage().equals(\"Missing target column\")) { /* fix DDL to include a column */ } else throw e; }","preventionTips":["Always write the column list in CREATE CUSTOM INDEX","Validate programmatically-built IndexMetadata options before attaching","Keep schema DDL in reviewed migrations, not generated ad hoc"],"tags":["cassandra","sai","invalid-request","missing-argument"],"backgroundTag":"missing-required-argument","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"}