apache/cassandra · error · InvalidRequestException

Table ' ' doesn't exist

Error message

Table '%s' doesn't exist

What it means

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.

Solutions

  1. Verify the table exists with DESCRIBE TABLES in the keyspace or query system_schema.tables
  2. Fix the table name in the statement
  3. Create the table before adding the trigger

Example fix

// before
CREATE TRIGGER trg ON ks.ordrs USING 'com.example.Trig';
// after
CREATE TRIGGER trg ON ks.orders USING 'com.example.Trig';
Defensive patterns

Strategy: validation

Validate before calling

const t = await session.execute("SELECT table_name FROM system_schema.tables WHERE keyspace_name = ? AND table_name = ?", [ks, table]);
if (t.rows.length === 0) throw new Error(`Table ${ks}.${table} does not exist`);

Try / catch

try { session.execute(triggerDdl); } catch (e) { if (/Table '.*' doesn't exist/.test(e.message)) { /* create table first or fix the name */ } else throw e; }

Prevention

When it happens

Trigger: CREATE TRIGGER trg ON ks.missing_table USING 'cls'; — the table was dropped, renamed, or never created in that keyspace.

Common situations: Typo in the table name; DDL run before the table-creation migration; wrong keyspace prefix causing lookup in the wrong namespace.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/bb6fc461592597ab. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTriggerStatement.java:89

    }

    @Override
    public boolean compatibleWith(ClusterMetadata metadata)
    {
        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
    }

    @Override
    public Keyspaces apply(ClusterMetadata metadata)
    {
        Keyspaces schema = metadata.schema.getKeyspaces();
        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
        if (null == keyspace)
            throw ire("Keyspace '%s' doesn't exist", keyspaceName);

        TableMetadata table = keyspace.getTableOrViewNullable(tableName);
        if (null == table)
            throw ire("Table '%s' doesn't exist", tableName);

        if (table.isView())
            throw ire("Cannot CREATE TRIGGER for a materialized view");

        TriggerMetadata existingTrigger = table.triggers.get(triggerName).orElse(null);
        if (null != existingTrigger)
        {
            if (ifNotExists)
                return schema;

            throw ire("Trigger '%s' already exists", triggerName);
        }

        try
        {
            TriggerExecutor.instance.loadTriggerClass(triggerClass);
        }
        catch (Exception e)

View on GitHub (pinned to 88fd0f6a0e)