{"record":{"id":"9c66f01bebb20ea3","repo":"apache/cassandra","slug":"non-frozen-collections-are-not-allowed-inside-coll","errorCode":null,"errorMessage":"Non-frozen collections are not allowed inside collections: ","messagePattern":"Non-frozen collections are not allowed inside collections: ","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/CQL3Type.java","lineNumber":897,"sourceCode":"\n                AbstractType<?> valueType = values.prepare(keyspace, udts).getType();\n                switch (kind)\n                {\n                    case LIST:\n                        return new Collection(ListType.getInstance(valueType, !frozen));\n                    case SET:\n                        return new Collection(SetType.getInstance(valueType, !frozen));\n                    case MAP:\n                        assert keys != null : \"Got null keys type for a collection\";\n                        return new Collection(MapType.getInstance(keys.prepare(keyspace, udts).getType(), valueType, !frozen));\n                }\n                throw new AssertionError();\n            }\n\n            private void throwNestedNonFrozenError(Raw innerType)\n            {\n                if (innerType instanceof RawCollection)\n                    throw new InvalidRequestException(\"Non-frozen collections are not allowed inside collections: \" + this);\n                else if (innerType.isUDT())\n                    throw new InvalidRequestException(\"Non-frozen UDTs are not allowed inside collections: \" + this);\n            }\n\n            public boolean referencesUserType(String name)\n            {\n                return (keys != null && keys.referencesUserType(name)) || values.referencesUserType(name);\n            }\n\n            @Override\n            public String toString()\n            {\n                String start = frozen? \"frozen<\" : \"\";\n                String end = frozen ? \">\" : \"\";\n                switch (kind)\n                {\n                    case LIST: return start + \"list<\" + values + '>' + end;\n                    case SET:  return start + \"set<\" + values + '>' + end;","sourceCodeStart":879,"sourceCodeEnd":915,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/CQL3Type.java#L879-L915","documentation":"A non-frozen collection (list/set/map) cannot be nested directly inside another collection. Multi-level collections must be explicitly frozen so they are stored as a single immutable blob rather than cell-per-element.","triggerScenarios":"Declaring e.g. `set<list<int>>`, `map<text, set<int>>`, or `list<map<text,text>>` without wrapping the inner collection in frozen<> in CREATE TABLE / ALTER TABLE.","commonSituations":"Very common during schema design when developers try deep nested types (JSON-like structures) in Cassandra; since 2.1.3+ nested collections exist but require frozen inner types.","solutions":["Wrap inner collections in frozen<>: `set<frozen<list<int>>>`","Restructure the data model into a separate table with clustering keys instead of nested collections","Freeze the outer collection entirely if whole-value updates are acceptable"],"exampleFix":"// before\nCREATE TABLE t (id uuid PRIMARY KEY, nested set<list<int>>);\n// after\nCREATE TABLE t (id uuid PRIMARY KEY, nested set<frozen<list<int>>>);","handlingStrategy":"validation","validationCode":"boolean hasNestedNonFrozenCollection(String typeDecl) {\n    String s = typeDecl.toLowerCase().replaceAll(\"\\\\s+\", \"\");\n    java.util.regex.Matcher m = java.util.regex.Pattern.compile(\"<((?!frozen<)[a-z]+<)\").matcher(s);\n    return m.find();\n}","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidQueryException e) { if (e.getMessage().startsWith(\"Non-frozen collections are not allowed inside collections\")) { /* wrap inner collection in frozen<> */ } else throw e; }","preventionTips":["Always wrap inner collections in frozen<> when nesting collections","Prefer flattened data models with clustering keys over nested collections","Remember non-frozen collections support per-cell updates but cannot nest"],"tags":["cql","schema","collection","frozen"],"backgroundTag":"schema-validation-failed","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"}