{"record":{"id":"82e7c30b133f5ceb","repo":"apache/cassandra","slug":"source-table-s-s-doesn-t-exist","errorCode":null,"errorMessage":"Source Table '%s.%s' doesn't exist","messagePattern":"Source Table '(.+?)\\.(.+?)' doesn't exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java","lineNumber":133,"sourceCode":"    @Override\n    public boolean compatibleWith(ClusterMetadata metadata)\n    {\n        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V5);\n    }\n\n    @Override\n    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata sourceKeyspaceMeta = schema.getNullable(sourceKeyspace);\n\n        if (null == sourceKeyspaceMeta)\n            throw ire(\"Source Keyspace '%s' doesn't exist\", sourceKeyspace);\n\n        TableMetadata sourceTableMeta = sourceKeyspaceMeta.getTableOrViewNullable(sourceTableName);\n\n        if (null == sourceTableMeta)\n            throw ire(\"Source Table '%s.%s' doesn't exist\", sourceKeyspace, sourceTableName);\n\n        if (sourceTableMeta.isIndex())\n            throw ire(\"Cannot use CREATE TABLE LIKE on an index table '%s.%s'.\", sourceKeyspace, sourceTableName);\n\n        if (sourceTableMeta.isView())\n            throw ire(\"Cannot use CREATE TABLE LIKE on a materialized view '%s.%s'.\", sourceKeyspace, sourceTableName);\n\n        KeyspaceMetadata targetKeyspaceMeta = schema.getNullable(targetKeyspace);\n        if (null == targetKeyspaceMeta)\n            throw ire(\"Target Keyspace '%s' doesn't exist\", targetKeyspace);\n\n        if (targetKeyspaceMeta.hasTable(targetTableName))\n        {\n            if (ifNotExists)\n                return schema;\n\n            throw new AlreadyExistsException(targetKeyspace, targetTableName);\n        }","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java#L115-L151","documentation":"CREATE TABLE LIKE could not find the source table within the (existing) source keyspace. apply() calls keyspaceMetadata.getTableOrViewNullable(sourceTableName) and throws this InvalidRequestException when null. The source must be an actual base table; missing names are rejected before type checks.","triggerScenarios":"`CREATE TABLE t2 LIKE <ks>.<missing>` where the table name is misspelled, the table was dropped, or the target is actually a view/index name in another lookup path; also when quoting/case differs.","commonSituations":"Typos in table names in migration scripts; schemas drifted between environments; assuming LIKE works against a materialized view or index (separate errors exist for those).","solutions":["List tables with `DESCRIBE TABLES` or system_schema.tables to confirm the source name","Correct the source table name (quote mixed-case identifiers)","Create/recreate the source table before running CREATE TABLE LIKE","If the intent was to copy a view/index structure, manually author the CREATE TABLE instead"],"exampleFix":"// before\nCREATE TABLE ks2.t2 LIKE ks.tabel1; -- typo\n\n// after\nCREATE TABLE ks2.t2 LIKE ks.table1;","handlingStrategy":"validation","validationCode":"// Ensure the source table exists\nconst rows = await session.execute(\n  \"SELECT table_name FROM system_schema.tables WHERE keyspace_name=? AND table_name=?\",\n  [srcKs, srcTable]);\nif (rows.rows.length === 0) throw new Error(`Source table ${srcKs}.${srcTable} does not exist`);","typeGuard":"null","tryCatchPattern":"try {\n  session.execute(`CREATE TABLE ks2.t2 LIKE ${srcKs}.${srcTable}`);\n} catch (e) {\n  if (/Source Table .* doesn't exist/.test(e.message)) {\n    // fix the name or create the table first\n  } else throw e;\n}","preventionTips":["Verify with system_schema.tables before copying","Quote mixed-case identifiers","Keep source names in per-environment config","Reconcile schema drift between environments before copy scripts"],"tags":["cassandra","cql","create-table-like","table-not-found"],"backgroundTag":"resource-not-found","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"}