{"record":{"id":"18b24dbe275e1ed1","repo":"apache/cassandra","slug":"a-user-type-with-name-s-already-exists","errorCode":null,"errorMessage":"A user type with name '%s' already exists","messagePattern":"A user type with name '(.+?)' already exists","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java","lineNumber":101,"sourceCode":"    public boolean compatibleWith(ClusterMetadata metadata)\n    {\n        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);\n    }\n\n    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n        if (null == keyspace)\n            throw ire(\"Keyspace '%s' doesn't exist\", keyspaceName);\n\n        UserType existingType = keyspace.types.getNullable(bytes(typeName));\n        if (null != existingType)\n        {\n            if (ifNotExists)\n                return schema;\n\n            throw ire(\"A user type with name '%s' already exists\", typeName);\n        }\n\n        Set<FieldIdentifier> usedNames = new HashSet<>();\n        for (FieldIdentifier name : fieldNames)\n            if (!usedNames.add(name))\n                throw ire(\"Duplicate field name '%s' in type '%s'\", name, typeName);\n\n        for (CQL3Type.Raw type : rawFieldTypes)\n        {\n            if (type.isCounter())\n                throw ire(\"A user type cannot contain counters\");\n\n            if (type.isUDT() && !type.isFrozen())\n                throw ire(\"A user type cannot contain non-frozen UDTs\");\n        }\n\n        List<AbstractType<?>> fieldTypes =\n            rawFieldTypes.stream()","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java#L83-L119","documentation":"Duplicate guard in CREATE TYPE: a user type with the same name already exists in the keyspace. Unless IF NOT EXISTS was given, the statement is rejected to prevent silently overwriting the existing type definition.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use IF NOT EXISTS to tolerate the existing type.","DROP TYPE the old definition or choose a different type name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}