{"record":{"id":"e795748909370f16","repo":"apache/cassandra","slug":"non-frozen-udts-with-nested-non-frozen-collections-e79574","errorCode":null,"errorMessage":"Non-frozen UDTs with nested non-frozen collections are not supported","messagePattern":"Non-frozen UDTs with nested non-frozen collections are not supported","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java","lineNumber":282,"sourceCode":"    public TableMetadata.Builder builder(Types types, UserFunctions functions)\n    {\n        attrs.validate();\n        TableParams params = attrs.asNewTableParams(keyspaceName);\n\n        // use a TreeMap to preserve ordering across JDK versions (see CASSANDRA-9492) - important for stable unit tests\n        Map<ColumnIdentifier, ColumnProperties> columns = new TreeMap<>(comparing(o -> o.bytes));\n        rawColumns.forEach((column, properties) -> columns.put(column, properties.prepare(keyspaceName, tableName, column, types, functions)));\n\n        // check for nested non-frozen UDTs or collections in a non-frozen UDT\n        columns.forEach((column, properties) ->\n        {\n            AbstractType<?> type = properties.type;\n            if (type.isUDT() && type.isMultiCell())\n            {\n                ((UserType) type).fieldTypes().forEach(field ->\n                {\n                    if (field.isMultiCell())\n                        throw ire(\"Non-frozen UDTs with nested non-frozen collections are not supported\");\n                });\n            }\n        });\n\n        /*\n         * Deal with PRIMARY KEY columns\n         */\n\n        HashSet<ColumnIdentifier> primaryKeyColumns = new HashSet<>();\n        concat(partitionKeyColumns, clusteringColumns).forEach(column ->\n        {\n            ColumnProperties properties = columns.get(column);\n            if (null == properties)\n                throw ire(\"Unknown column '%s' referenced in PRIMARY KEY for table '%s'\", column, tableName);\n\n            if (!primaryKeyColumns.add(column))\n                throw ire(\"Duplicate column '%s' in PRIMARY KEY clause for table '%s'\", column, tableName);\n","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java#L264-L300","documentation":"A non-frozen (multi-cell) user-defined type whose fields themselves are multi-cell collections/UDTs cannot be used for a table column. Nested non-frozen types are unsupported in Cassandra's type system, so the builder rejects the column definition.","triggerScenarios":"Declaring a column of a non-frozen UDT that contains a non-frozen collection field (e.g. `CREATE TYPE t (m map<text, int>); CREATE TABLE tb (... u frozen-free t ...)` where the UDT is used unfrozen).","commonSituations":"Modeling nested JSON-like structures in CQL; users expecting map/list fields inside UDTs to work like normal columns.","solutions":["Freeze the UDT at the column definition: `col frozen<mytype>`","Freeze the nested collection inside the UDT definition (e.g. `frozen<map<text,int>>`) so no field is multi-cell","Restructure the schema to avoid nesting, using a separate table"],"exampleFix":"// before\nCREATE TABLE ks.t (k int PRIMARY KEY, v my_udt); // my_udt has non-frozen collection field\n// after\nCREATE TABLE ks.t (k int PRIMARY KEY, v frozen<my_udt>);","handlingStrategy":"validation","validationCode":"for each UDT column used unfrozen: if (udt.fieldTypes().stream().anyMatch(AbstractType::isMultiCell)) freeze the column as frozen<udt>;","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"Non-frozen UDTs with nested non-frozen collections\")) { /* rewrite column as frozen<udt> */ } else throw e; }","preventionTips":["Freeze UDTs by default unless multi-cell behavior is required","Keep UDT field definitions free of unfrozen collections","Test DDL against the target Cassandra version before deploying"],"tags":["cql","udt","types","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-17T15:17:12.973Z"}