apache/cassandra · error · InvalidRequestException
Non-frozen collections are not allowed inside collections:
Error message
Non-frozen collections are not allowed inside collections:
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/cql3/CQL3Type.java:897
AbstractType<?> valueType = values.prepare(keyspace, udts).getType();
switch (kind)
{
case LIST:
return new Collection(ListType.getInstance(valueType, !frozen));
case SET:
return new Collection(SetType.getInstance(valueType, !frozen));
case MAP:
assert keys != null : "Got null keys type for a collection";
return new Collection(MapType.getInstance(keys.prepare(keyspace, udts).getType(), valueType, !frozen));
}
throw new AssertionError();
}
private void throwNestedNonFrozenError(Raw innerType)
{
if (innerType instanceof RawCollection)
throw new InvalidRequestException("Non-frozen collections are not allowed inside collections: " + this);
else if (innerType.isUDT())
throw new InvalidRequestException("Non-frozen UDTs are not allowed inside collections: " + this);
}
public boolean referencesUserType(String name)
{
return (keys != null && keys.referencesUserType(name)) || values.referencesUserType(name);
}
@Override
public String toString()
{
String start = frozen? "frozen<" : "";
String end = frozen ? ">" : "";
switch (kind)
{
case LIST: return start + "list<" + values + '>' + end;
case SET: return start + "set<" + values + '>' + end;View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before CREATE TABLE t (id uuid PRIMARY KEY, nested set<list<int>>); // after CREATE TABLE t (id uuid PRIMARY KEY, nested set<frozen<list<int>>>);
Defensive patterns
Strategy: validation
Validate before calling
boolean hasNestedNonFrozenCollection(String typeDecl) {
String s = typeDecl.toLowerCase().replaceAll("\\s+", "");
java.util.regex.Matcher m = java.util.regex.Pattern.compile("<((?!frozen<)[a-z]+<)").matcher(s);
return m.find();
} Try / catch
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; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- frozen<> is only allowed on collections, tuples, and user-de
- Counters are not allowed inside collections:
- Non-frozen UDTs are not allowed inside collections:
- Invalid operation (%s) for frozen list column %s
- Constraint cannot be defined on the column <name> of type <t
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/9c66f01bebb20ea3.
Report an issue: GitHub.