apache/cassandra · error · InvalidRequestException
Source Table '%s.%s' doesn't exist
Error message
Source Table '%s.%s' doesn't exist
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java:133
@Override
public boolean compatibleWith(ClusterMetadata metadata)
{
return metadata.directory.commonSerializationVersion.isAtLeast(Version.V5);
}
@Override
public Keyspaces apply(ClusterMetadata metadata)
{
Keyspaces schema = metadata.schema.getKeyspaces();
KeyspaceMetadata sourceKeyspaceMeta = schema.getNullable(sourceKeyspace);
if (null == sourceKeyspaceMeta)
throw ire("Source Keyspace '%s' doesn't exist", sourceKeyspace);
TableMetadata sourceTableMeta = sourceKeyspaceMeta.getTableOrViewNullable(sourceTableName);
if (null == sourceTableMeta)
throw ire("Source Table '%s.%s' doesn't exist", sourceKeyspace, sourceTableName);
if (sourceTableMeta.isIndex())
throw ire("Cannot use CREATE TABLE LIKE on an index table '%s.%s'.", sourceKeyspace, sourceTableName);
if (sourceTableMeta.isView())
throw ire("Cannot use CREATE TABLE LIKE on a materialized view '%s.%s'.", sourceKeyspace, sourceTableName);
KeyspaceMetadata targetKeyspaceMeta = schema.getNullable(targetKeyspace);
if (null == targetKeyspaceMeta)
throw ire("Target Keyspace '%s' doesn't exist", targetKeyspace);
if (targetKeyspaceMeta.hasTable(targetTableName))
{
if (ifNotExists)
return schema;
throw new AlreadyExistsException(targetKeyspace, targetTableName);
}View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before CREATE TABLE ks2.t2 LIKE ks.tabel1; -- typo // after CREATE TABLE ks2.t2 LIKE ks.table1;
Defensive patterns
Strategy: validation
Validate before calling
// Ensure the source table exists
const rows = await session.execute(
"SELECT table_name FROM system_schema.tables WHERE keyspace_name=? AND table_name=?",
[srcKs, srcTable]);
if (rows.rows.length === 0) throw new Error(`Source table ${srcKs}.${srcTable} does not exist`); Type guard
null
Try / catch
try {
session.execute(`CREATE TABLE ks2.t2 LIKE ${srcKs}.${srcTable}`);
} catch (e) {
if (/Source Table .* doesn't exist/.test(e.message)) {
// fix the name or create the table first
} else throw e;
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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).
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Table '%s.%s' doesn't exist
- Source Keyspace '%s' doesn't exist
- Cannot use CREATE TABLE LIKE on an index table '%s.%s'.
- Cannot use CREATE TABLE LIKE on a materialized view '%s.%s'.
- Target Keyspace '%s' doesn't exist
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/82e7c30b133f5ceb.
Report an issue: GitHub.