{"record":{"id":"9a19d2304a169a8c","repo":"apache/cassandra","slug":"element-selection-not-supported-for-column-s-of-t","errorCode":null,"errorMessage":"Element selection not supported for column %s of type %s","messagePattern":"Element selection not supported for column (.+?) of type (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/transactions/RowDataReference.java","lineNumber":137,"sourceCode":"        {\n            forMetadata = forMetadata.withNewType(getFieldSelectionType());\n        }\n        return forMetadata;\n    }\n\n    public ColumnSpecification getValueReceiver()\n    {\n        if (isElementSelection())\n        {\n            CollectionType.Kind collectionKind = ((CollectionType<?>) column.type).kind;\n            switch (collectionKind)\n            {\n                case LIST:\n                    return Lists.valueSpecOf(column);\n                case MAP:\n                    return Maps.valueSpecOf(column);\n                default:\n                    throw new InvalidRequestException(String.format(\"Element selection not supported for column %s of type %s\" ,\n                                                                    column.name, collectionKind));\n            }\n        }\n        else if (isFieldSelection())\n        {\n            return getFieldSelectionSpec();\n        }\n\n        return column;\n    }\n\n    public boolean isElementSelection()\n    {\n        return elementPath != null && column.type.isCollection();\n    }\n\n    public boolean isFieldSelection()\n    {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/transactions/RowDataReference.java#L119-L155","documentation":"In transactional row data references, element selection (e.g. `m[key]` or `l[i]`) is only supported for MAP and LIST collections. getValueReceiver throws this InvalidRequestException for any other collection kind (e.g. SET) when an element path is supplied.","triggerScenarios":"A transaction partial-reference like `SELECT col[k]` or a TxnUpdate referencing an element of a SET column, or a non-collection column misused with an element selector.","commonSituations":"Trying to read/update a single element of a set inside a lightweight-transaction/transaction block; element selection attempted on a frozen collection where per-element access isn't meaningful.","solutions":["Use map or list columns when per-element transactional access is needed.","Reference the whole SET column value instead of an element.","Unfreeze/restructure the schema: replace set<text> with map<text,text> if keyed access is required."],"exampleFix":"// before\nUPDATE ks.t SET tags['x'] = '1' WHERE ...; // tags is set<text>\n// after\nUPDATE ks.t SET tags = tags + {'x'} WHERE ...; // whole-collection op, or use map<text,text>","handlingStrategy":"validation","validationCode":"if (column.type.asCQL3Type().getKind() == SET && hasElementSelection(column))\n    throw new IllegalArgumentException(\"Element selection not supported for set column \" + column.name);","typeGuard":null,"tryCatchPattern":"try { session.execute(txnStmt); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"Element selection not supported\")) rewriteAsWholeCollection(); else throw e; }","preventionTips":["Use map/list for per-element transactional access","Avoid element selectors on sets and frozen collections","Review transaction references for collection kinds"],"tags":["cql","transactions","collections"],"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"}