{"record":{"id":"ae8c09ac4d8c4f9c","repo":"apache/cassandra","slug":"udts-s-do-not-exist-in-target-keyspace-s","errorCode":null,"errorMessage":"UDTs %s do not exist in target keyspace '%s'.","messagePattern":"UDTs (.+?) do not exist in target keyspace '(.+?)'\\.","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java","lineNumber":176,"sourceCode":"            {\n                Optional<UserType> targetUserType = targetKeyspaceMeta.types.get(sourceUserTypeName);\n                Optional<UserType> sourceUserType = sourceKeyspaceMeta.types.get(sourceUserTypeName);\n                if (targetUserType.isPresent() && sourceUserType.isPresent())\n                {\n                    if (!sourceUserType.get().equalsWithOutKs(targetUserType.get()))\n                        throw ire(\"Target keyspace '%s' has same UDT name '%s' as source keyspace '%s' but with different structure.\",\n                                  targetKeyspace,\n                                  UTF8Type.instance.getString(targetUserType.get().name),\n                                  sourceKeyspace);\n                }\n                else\n                {\n                    missingUserTypes.add(UTF8Type.instance.compose(sourceUserTypeName));\n                }\n            }\n\n            if (!missingUserTypes.isEmpty())\n                throw ire(\"UDTs %s do not exist in target keyspace '%s'.\",\n                          missingUserTypes.stream().sorted().collect(Collectors.joining(\", \")),\n                          targetKeyspace);\n        }\n\n        // Guardrail on columns per table\n        Guardrails.columnsPerTable.guard(sourceTableMeta.columns().size(), targetTableName, false, state);\n\n        sourceTableMeta.columns().forEach(columnMetadata -> {\n            if (columnMetadata.type.isVector())\n            {\n                Guardrails.vectorTypeEnabled.ensureEnabled(columnMetadata.name.toString(), state);\n                int dimensions = ((VectorType) columnMetadata.type).dimension;\n                Guardrails.vectorDimensions.guard(dimensions, columnMetadata.name.toString(), false, state);\n            }\n        });\n\n        // Guardrail to check whether creation of new COMPACT STORAGE tables is allowed\n        if (sourceTableMeta.isCompactTable())","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java#L158-L194","documentation":"CopyTableStatement.apply validation: the source table references user-defined types that are absent from the target keyspace, so the table cannot be copied until those UDTs exist there. Thrown as InvalidRequestException during schema transformation.","triggerScenarios":"CopyTableStatement.apply with one or more source UDT names having no counterpart (Optional.empty) in targetKeyspaceMeta.types; the message lists the missing names sorted.","commonSituations":"Copying a table into a fresh keyspace without first creating its UDTs; running schema-restore scripts out of order (table before types).","solutions":["Create the listed UDT(s) in the target keyspace with identical structure before re-running the copy","Copy the full schema (keyspace with types) rather than just the table","Run statements in dependency order: CREATE TYPE before CREATE TABLE"],"exampleFix":"// before\nCREATE TABLE tgt.t ... -- fails: UDT addr missing in tgt\n// after\nCREATE TYPE tgt.addr (street text, zip int);\nCREATE TABLE tgt.t ...","handlingStrategy":"validation","validationCode":"List<String> missing = sourceTable.columns.stream()\n    .flatMap(c -> referencedUdts(c.type).stream())\n    .filter(n -> !targetKs.types.get(UTF8Type.instance.decompose(n)).isPresent())\n    .collect(Collectors.toList());\nif (!missing.isEmpty()) throw new IllegalStateException(\"Missing UDTs in target: \" + missing);","typeGuard":null,"tryCatchPattern":"try { copyTable(...); }\ncatch (InvalidRequestException e) { if (e.getMessage().startsWith(\"UDTs \")) createMissingUdts(parseNames(e.getMessage()), targetKs); else throw e; }","preventionTips":["Always create all UDTs in the target keyspace before copying tables","Migrate schemas as complete units (types + tables), never tables alone","Maintain an ordered migration script: keyspaces, types, functions, then tables"],"tags":["cql","udt","schema","missing-type"],"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"}