{"record":{"id":"d90599a427334c95","repo":"apache/cassandra","slug":"invalid-deletion-operation-for-frozen-collection-c","errorCode":null,"errorMessage":"Invalid deletion operation for frozen collection column %s","messagePattern":"Invalid deletion operation for frozen collection column (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Operation.java","lineNumber":526,"sourceCode":"        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    }\n\n    public static class FieldDeletion implements RawDeletion","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Operation.java#L508-L544","documentation":"An element-level DELETE was issued against a frozen collection column. Frozen collections cannot be partially mutated (including element deletion) because they are stored as a single cell; prepare rejects the operation.","triggerScenarios":"`DELETE m['k'] FROM t` where m is frozen<map<...>>; `DELETE l[0] FROM t` where l is frozen<list<...>>.","commonSituations":"Frozen types chosen for PK/index compatibility, then later element deletes attempted; schema conversions from non-frozen to frozen without query updates.","solutions":["Remove the frozen wrapper (recreate the column/table) so element deletes are supported","Rewrite as a full-value update: read the frozen collection, remove the element client-side, SET the new value","Use `DELETE col FROM t` only if discarding the entire value is acceptable","Redesign the data model (e.g. non-frozen collection or separate rows) if partial mutation is a core requirement"],"exampleFix":"// before\nm frozen<map<text,text>>; DELETE m['k'] FROM t WHERE id=1;\n// after\nm map<text,text>; DELETE m['k'] 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.contains(\"frozen\")) throw new IllegalStateException(\"frozen collections do not support element deletes\");","typeGuard":null,"tryCatchPattern":"try { session.execute(\"DELETE col[k] FROM t WHERE id=?\", id); } catch (InvalidQueryException e) { if (e.getMessage().contains(\"frozen collection\")) { /* full-value rewrite */ } else throw e; }","preventionTips":["Avoid frozen collection types when element-level deletes are planned","For frozen values, read-modify-write the entire value","Review schema definitions when porting queries between tables"],"tags":["cql","delete","frozen","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"}