{"record":{"id":"bb6fc461592597ab","repo":"apache/cassandra","slug":"table-s-doesn-t-exist-bb6fc4","errorCode":null,"errorMessage":"Table '%s' doesn't exist","messagePattern":"Table '(.+?)' doesn't exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTriggerStatement.java","lineNumber":89,"sourceCode":"    }\n\n    @Override\n    public boolean compatibleWith(ClusterMetadata metadata)\n    {\n        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);\n    }\n\n    @Override\n    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n        if (null == keyspace)\n            throw ire(\"Keyspace '%s' doesn't exist\", keyspaceName);\n\n        TableMetadata table = keyspace.getTableOrViewNullable(tableName);\n        if (null == table)\n            throw ire(\"Table '%s' doesn't exist\", tableName);\n\n        if (table.isView())\n            throw ire(\"Cannot CREATE TRIGGER for a materialized view\");\n\n        TriggerMetadata existingTrigger = table.triggers.get(triggerName).orElse(null);\n        if (null != existingTrigger)\n        {\n            if (ifNotExists)\n                return schema;\n\n            throw ire(\"Trigger '%s' already exists\", triggerName);\n        }\n\n        try\n        {\n            TriggerExecutor.instance.loadTriggerClass(triggerClass);\n        }\n        catch (Exception e)","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTriggerStatement.java#L71-L107","documentation":"CREATE TRIGGER references a table that does not exist within the (already resolved) keyspace. apply() fetches TableMetadata via getTableOrViewNullable and throws when null; note it fires before the materialized-view check, so tables and views are both considered absent names.","triggerScenarios":"CREATE TRIGGER trg ON ks.missing_table USING 'cls'; — the table was dropped, renamed, or never created in that keyspace.","commonSituations":"Typo in the table name; DDL run before the table-creation migration; wrong keyspace prefix causing lookup in the wrong namespace.","solutions":["Verify the table exists with DESCRIBE TABLES in the keyspace or query system_schema.tables","Fix the table name in the statement","Create the table before adding the trigger"],"exampleFix":"// before\nCREATE TRIGGER trg ON ks.ordrs USING 'com.example.Trig';\n// after\nCREATE TRIGGER trg ON ks.orders USING 'com.example.Trig';","handlingStrategy":"validation","validationCode":"const t = await session.execute(\"SELECT table_name FROM system_schema.tables WHERE keyspace_name = ? AND table_name = ?\", [ks, table]);\nif (t.rows.length === 0) throw new Error(`Table ${ks}.${table} does not exist`);","typeGuard":null,"tryCatchPattern":"try { session.execute(triggerDdl); } catch (e) { if (/Table '.*' doesn't exist/.test(e.message)) { /* create table first or fix the name */ } else throw e; }","preventionTips":["Ensure table-creation migrations run before trigger DDL","Verify names with DESCRIBE TABLES or system_schema.tables","Qualify the table name with the intended keyspace"],"tags":["cql","trigger","table"],"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"}