{"record":{"id":"6dc48f8eb73523a2","repo":"apache/cassandra","slug":"table-s-does-not-exist","errorCode":null,"errorMessage":"table %s does not exist","messagePattern":"table (.+?) does not exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/SchemaProvider.java","lineNumber":106,"sourceCode":"    }\n\n    default Keyspaces getNonLocalStrategyKeyspaces()\n    {\n        return distributedKeyspaces().filter(keyspace -> keyspace.params.replication.klass != LocalStrategy.class);\n    }\n\n    default TableMetadata validateTable(String keyspaceName, String tableName)\n    {\n        if (tableName.isEmpty())\n            throw new InvalidRequestException(\"non-empty table is required\");\n\n        KeyspaceMetadata keyspace = getKeyspaceMetadata(keyspaceName);\n        if (keyspace == null)\n            throw new KeyspaceNotDefinedException(String.format(\"keyspace %s does not exist\", keyspaceName));\n\n        TableMetadata metadata = keyspace.getTableOrViewNullable(tableName);\n        if (metadata == null)\n            throw new InvalidRequestException(String.format(\"table %s does not exist\", tableName));\n\n        return metadata;\n    }\n\n    default ColumnFamilyStore getColumnFamilyStoreInstance(TableId id)\n    {\n        TableMetadata metadata = getTableMetadata(id);\n        if (metadata == null)\n            return null;\n\n        Keyspace instance = getKeyspaceInstance(metadata.keyspace);\n        if (instance == null)\n            return null;\n\n        return instance.hasColumnFamilyStore(metadata.id)\n               ? instance.getColumnFamilyStore(metadata.id)\n               : null;\n    }","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/SchemaProvider.java#L88-L124","documentation":"validateTable throws InvalidRequestException('table %s does not exist') when the keyspace exists but contains no table (or view) with the given name. The lookup is done against the keyspace's metadata via getTableOrViewNullable.","triggerScenarios":"Querying/altering a table that was never created or was dropped; case mismatch (quoted \"Events\" vs events); referencing a view name where only a table exists; statement targeting the wrong keyspace.","commonSituations":"Typos in table names, migrations out of order (table creation not yet run), a replica with lagging schema answering before table creation propagates, ORMs mapping entities to missing tables.","solutions":["Verify the table exists with DESCRIBE TABLES / system_schema.tables in that keyspace.","Create the table or fix the name/case in the statement (use quoted identifiers for case-sensitive names).","Ensure schema agreement before issuing statements right after DDL."],"exampleFix":"// before\nsession.execute(\"INSERT INTO ks.userevents (id) VALUES (1)\"); // table is actually user_events\n// after\nsession.execute(\"INSERT INTO ks.user_events (id) VALUES (1)\");","handlingStrategy":"validation","validationCode":"boolean tableExists(Session s, String ks, String table) {\n    return s.execute(\"SELECT table_name FROM system_schema.tables WHERE keyspace_name = ? AND table_name = ?\",\n                     ks.toLowerCase(), table.toLowerCase()).one() != null;\n}","typeGuard":null,"tryCatchPattern":"try { session.execute(query); }\ncatch (InvalidRequestException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"does not exist\"))\n        logger.error(\"Table {}.{} missing — check migrations/typos\", ks, table);\n    throw e;\n}","preventionTips":["Keep a single source of truth (migration tool) for table names shared between app and schema.","Wait for schema agreement after CREATE TABLE before issuing DML.","Check case-sensitivity: quoted identifiers preserve case, unquoted are lowercased."],"tags":["schema","table","not-found"],"backgroundTag":"record-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"}