{"record":{"id":"e07bb126aa79d1ce","repo":"apache/cassandra","slug":"invalid-non-frozen-user-defined-type-s-for-primar","errorCode":null,"errorMessage":"Invalid non-frozen user-defined type %s for PRIMARY KEY column '%s'","messagePattern":"Invalid non-frozen user-defined type (.+?) for PRIMARY KEY column '(.+?)'","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java","lineNumber":308,"sourceCode":"\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\n            AbstractType<?> type = properties.type;\n            if (type.isMultiCell())\n            {\n                CQL3Type cqlType = properties.cqlType;\n                if (type.isCollection())\n                    throw ire(\"Invalid non-frozen collection type %s for PRIMARY KEY column '%s'\", cqlType, column);\n                else\n                    throw ire(\"Invalid non-frozen user-defined type %s for PRIMARY KEY column '%s'\", cqlType, column);\n            }\n\n            if (type.isCounter())\n                throw ire(\"counter type is not supported for PRIMARY KEY column '%s'\", column);\n\n            if (type.referencesDuration())\n                throw ire(\"duration type is not supported for PRIMARY KEY column '%s'\", column);\n\n            if (staticColumns.contains(column))\n                throw ire(\"Static column '%s' cannot be part of the PRIMARY KEY\", column);\n        });\n\n        List<ColumnProperties> partitionKeyColumnProperties = new ArrayList<>();\n        List<ColumnProperties> clusteringColumnProperties = new ArrayList<>();\n\n        partitionKeyColumns.forEach(column ->\n        {\n            ColumnProperties columnProperties = columns.remove(column);","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java#L290-L326","documentation":"Thrown from CreateTableStatement's builder while validating PRIMARY KEY columns when a key column's type is a multi-cell (non-frozen) user-defined type — detected via type.isMultiCell() on a type that is not a collection. Primary key columns must be fully frozen so their serialized form is stable, hence the non-frozen UDT is rejected.","triggerScenarios":"`CREATE TABLE t (u my_udt, PRIMARY KEY (u))` where my_udt is used without frozen<>.","commonSituations":"Using a UDT as a composite key for readability; generated schemas placing UDT columns in keys without freezing.","solutions":["Freeze the UDT in the column definition: `u frozen<my_udt>`","Flatten the UDT fields into separate clustering/partition columns","Use a tuple type instead of a UDT for the key"],"exampleFix":"// before\nCREATE TABLE t (u my_udt, PRIMARY KEY (u));\n// after\nCREATE TABLE t (u frozen<my_udt>, PRIMARY KEY (u));","handlingStrategy":"validation","validationCode":"if (keyColumnType.isUDT() && keyColumnType.isMultiCell()) throw new IllegalArgumentException(\"wrap UDT key column in frozen<>\");","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"Invalid non-frozen user-defined type\")) { /* rewrite column as frozen<udt> */ } else throw e; }","preventionTips":["Always freeze UDTs used in PRIMARY KEY positions","Prefer flattening UDT fields into explicit key columns","Document the frozen<> requirement for key-typed UDTs in schema guidelines"],"tags":["cql","udt","primary-key","types"],"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"}