{"record":{"id":"7f0eea132836a378","repo":"apache/cassandra","slug":"non-frozen-collections-and-udts-are-not-supported","errorCode":null,"errorMessage":"Non-frozen collections and UDTs are not supported with COMPACT STORAGE","messagePattern":"Non-frozen collections and UDTs are not supported with COMPACT STORAGE","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java","lineNumber":436,"sourceCode":"        {\n            columns.forEach((column, properties) -> {\n                if (staticColumns.contains(column))\n                    builder.addStaticColumn(column, properties.type, properties.mask, columnConstraints.get(column));\n                else\n                    builder.addRegularColumn(column, properties.type, properties.mask, columnConstraints.get(column));\n            });\n        }\n\n        return builder;\n    }\n\n    private void validateCompactTable(List<ColumnProperties> clusteringColumnProperties,\n                                      Map<ColumnIdentifier, ColumnProperties> columns)\n    {\n        boolean isDense = !clusteringColumnProperties.isEmpty();\n\n        if (columns.values().stream().anyMatch(c -> c.type.isMultiCell()))\n            throw ire(\"Non-frozen collections and UDTs are not supported with COMPACT STORAGE\");\n        if (!staticColumns.isEmpty())\n            throw ire(\"Static columns are not supported in COMPACT STORAGE tables\");\n\n        if (clusteringColumnProperties.isEmpty())\n        {\n            // It's a thrift \"static CF\" so there should be some columns definition\n            if (columns.isEmpty())\n                throw ire(\"No definition found that is not part of the PRIMARY KEY\");\n        }\n\n        if (isDense)\n        {\n            // We can have no columns (only the PK), but we can't have more than one.\n            if (columns.size() > 1)\n                throw ire(String.format(\"COMPACT STORAGE with composite PRIMARY KEY allows no more than one column not part of the PRIMARY KEY (got: %s)\", StringUtils.join(columns.keySet(), \", \")));\n        }\n        else\n        {","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java#L418-L454","documentation":"COMPACT STORAGE tables emulate legacy Thrift layouts, which cannot represent non-frozen (multi-cell) collections or user-defined types. The compact-table validator rejects any column whose type is multi-cell, throwing this error at CREATE TABLE time.","triggerScenarios":"CREATE TABLE ... WITH COMPACT STORAGE where any column is a non-frozen list, set, map, or UDT.","commonSituations":"Porting a modern schema to COMPACT STORAGE for thrift compatibility; adding a collection column to an existing COMPACT STORAGE table via ALTER.","solutions":["Freeze the collection/UDT: use frozen<set<int>>, frozen<map<...>>, or frozen<my_udt>.","Drop the COMPACT STORAGE option and use a standard table.","Remove the collection column from the compact table."],"exampleFix":"// before\nCREATE TABLE t (pk int PRIMARY KEY, tags set<int>) WITH COMPACT STORAGE;\n// after\nCREATE TABLE t (pk int PRIMARY KEY, tags frozen<set<int>>) WITH COMPACT STORAGE;","handlingStrategy":"validation","validationCode":"// With COMPACT STORAGE, collections/UDTs must be frozen:\nboolean compactStorage = true;\nList<String> colTypes = List.of(\"set<int>\"); // non-frozen multi-cell types rejected\nif (compactStorage && colTypes.stream().anyMatch(t -> t.matches(\"(set|list|map)<.*>\") && !t.startsWith(\"frozen<\"))) throw new IllegalArgumentException(\"freeze collections/UDTs or drop COMPACT STORAGE\");","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (com.datastax.driver.core.exceptions.InvalidQueryException e) { if (e.getMessage().contains(\"Non-frozen collections\")) { /* freeze type or drop COMPACT STORAGE */ } else throw e; }","preventionTips":["Freeze all collections and UDTs in COMPACT STORAGE tables.","Avoid combining COMPACT STORAGE with modern multi-cell types.","Prefer regular tables unless legacy Thrift compatibility is required."],"tags":["cql","schema","compact-storage","collections"],"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"}