{"record":{"id":"e449d73d88a98069","repo":"apache/cassandra","slug":"invalid-deletion-operation-for-non-collection-colu","errorCode":null,"errorMessage":"Invalid deletion operation for non collection column %s","messagePattern":"Invalid deletion operation for non collection column (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Operation.java","lineNumber":524,"sourceCode":"    {\n        private final ColumnIdentifier id;\n        private final Term.Raw element;\n\n        public ElementDeletion(ColumnIdentifier id, Term.Raw element)\n        {\n            this.id = id;\n            this.element = element;\n        }\n\n        public ColumnIdentifier affectedColumn()\n        {\n            return id;\n        }\n\n        public Operation prepare(String keyspace, ColumnMetadata receiver, TableMetadata metadata) throws InvalidRequestException\n        {\n            if (!(receiver.type.isCollection()))\n                throw new InvalidRequestException(String.format(\"Invalid deletion operation for non collection column %s\", receiver.name));\n            else if (!(receiver.type.isMultiCell()))\n                throw new InvalidRequestException(String.format(\"Invalid deletion operation for frozen collection column %s\", receiver.name));\n\n            switch (((CollectionType<?>)receiver.type).kind)\n            {\n                case LIST:\n                    Term idx = element.prepare(keyspace, Lists.indexSpecOf(receiver));\n                    return new Lists.DiscarderByIndex(receiver, idx);\n                case SET:\n                    Term elt = element.prepare(keyspace, Sets.valueSpecOf(receiver));\n                    return new Sets.ElementDiscarder(receiver, elt);\n                case MAP:\n                    Term key = element.prepare(keyspace, Maps.keySpecOf(receiver));\n                    return new Maps.DiscarderByKey(receiver, key);\n            }\n            throw new AssertionError();\n        }\n    }","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Operation.java#L506-L542","documentation":"An element/field-level DELETE (e.g. `DELETE tags['k'] FROM t` or `DELETE l[0] FROM t`) was issued against a column that is not a collection. Only collection columns support partial deletion operations, so prepare rejects it.","triggerScenarios":"`DELETE col[key] FROM t ...` where col is a scalar (text, int, etc.) or non-collection UDT usage; element index syntax applied to plain columns.","commonSituations":"Assuming JSON-path-like deletion on scalar columns; schema drift (column changed from map to text); typos targeting the wrong column.","solutions":["Verify the column is a non-frozen collection via DESCRIBE TABLE","To delete a scalar entirely use `DELETE col FROM t WHERE ...` (whole column tombstone), not element syntax","Fix the column name in the statement if a typo targeted the wrong column","Recreate/migrate the column as a collection if partial deletion semantics are required"],"exampleFix":"// before (col is text)\nDELETE col['k'] FROM t WHERE id=1;\n// after\nDELETE col FROM t WHERE id=1;","handlingStrategy":"validation","validationCode":"String type = session.execute(\"SELECT type FROM system_schema.columns WHERE keyspace_name=? AND table_name=? AND column_name=?\", ks, table, col).one().getString(\"type\");\nif (!(type.startsWith(\"list\") || type.startsWith(\"set\") || type.startsWith(\"map\"))) throw new IllegalStateException(\"element delete requires a collection column\");","typeGuard":null,"tryCatchPattern":"try { session.execute(\"DELETE col[key] FROM t WHERE k=?\", k); } catch (InvalidQueryException e) { if (e.getMessage().contains(\"non collection column\")) { /* delete whole column instead */ } else throw e; }","preventionTips":["Reserve col[key] delete syntax for non-frozen collections","Delete scalar columns wholesale, not by element","Validate column names against schema to catch typos"],"tags":["cql","delete","collections","schema"],"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"}