{"record":{"id":"a80a46c8af2d1c78","repo":"apache/cassandra","slug":"type-s-s-doesn-t-exist-a80a46","errorCode":null,"errorMessage":"Type '%s.%s' doesn't exist","messagePattern":"Type '(.+?)\\.(.+?)' doesn't exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/DropTypeStatement.java","lineNumber":81,"sourceCode":"    // TODO: expand types into tuples in all dropped columns of all tables\n    @Override\n    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        ByteBuffer name = bytes(typeName);\n\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n\n        UserType type = null == keyspace\n                      ? null\n                      : keyspace.types.getNullable(name);\n\n        if (null == type)\n        {\n            if (ifExists)\n                return schema;\n\n            throw ire(\"Type '%s.%s' doesn't exist\", keyspaceName, typeName);\n        }\n\n        /*\n         * We don't want to drop a type unless it's not used anymore (mainly because\n         * if someone drops a type and recreates one with the same name but different\n         * definition with the previous name still in use, things can get messy).\n         * We have three places to check:\n         * 1) UDFs and UDAs using the type\n         * 2) other user type that can nest the one we drop and\n         * 3) existing tables referencing the type (maybe in a nested way).\n         */\n        Iterable<UserFunction> functions = keyspace.userFunctions.referencingUserType(name);\n        if (!isEmpty(functions))\n        {\n            throw ire(\"Cannot drop user type '%s.%s' as it is still used by functions %s\",\n                      keyspaceName,\n                      typeName,\n                      join(\", \", transform(functions, f -> f.name().toString())));","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/DropTypeStatement.java#L63-L99","documentation":"Existence guard in DropTypeStatement.apply(): the user type named in DROP TYPE cannot be resolved — either the keyspace is missing or keyspace.types has no entry for typeName. Without IF EXISTS, the statement fails with InvalidRequestException identifying the nonexistent type.","triggerScenarios":"Executing DROP TYPE <ks>.<type> for a type name not present in keyspace.types; misspelling the type; re-running a script after the type was already dropped; running against the wrong keyspace (useKeyspace not set).","commonSituations":"Scripts run twice; typos; connecting to a cluster where the UDT was never created; case-sensitivity confusion with quoted identifiers.","solutions":["Add IF EXISTS to tolerate an already-dropped type; confirm the type exists with DESCRIBE TYPE; check the keyspace qualification and spelling of the type name."],"exampleFix":"// before\nDROP TYPE ks.address;\n// after\nDROP TYPE IF EXISTS ks.address;","handlingStrategy":"validation","validationCode":"var exists = session.execute(\"SELECT type_name FROM system_schema.types WHERE keyspace_name=? AND type_name=?\", ks, type).iterator().hasNext();\nif (exists) session.execute(\"DROP TYPE IF EXISTS \" + ks + \".\" + type);","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidRequest e) { if (e.getMessage().contains(\"doesn't exist\")) log.info(\"Type already absent\"); else throw e; }","preventionTips":["Use IF EXISTS for idempotent DDL","Confirm the current keyspace (USE statement) before DROP TYPE","Beware identifier case sensitivity with quoted names"],"tags":["cassandra","cql","ddl","udt"],"backgroundTag":"entity-not-found","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"}