apache/cassandra · error · InvalidRequestException

Index ' . ' doesn't exist

Error message

Index '%s.%s' doesn't exist'

What it means

DROP INDEX failed because the named index does not exist (or the backing table does not exist) and IF EXISTS was not given. Note the message contains a stray trailing quote ("doesn't exist'") — that typo is in the source string itself.

Solutions

  1. Check the actual index name via system_schema.indexes or DESCribe TABLE.
  2. Add IF EXISTS: DROP INDEX IF EXISTS ks.index_name.
  3. Verify the keyspace name is correct.

Example fix

// before
DROP INDEX ks.user_email_idx;
// after
DROP INDEX IF EXISTS ks.users_email_idx;
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = schema.getKeyspace(ks).tables.stream()
    .flatMap(t -> t.indexes.stream())
    .anyMatch(i -> i.name.equals(idxName));
if (!exists) skipOrUseIfExists();

Try / catch

try { dropIndex(...); } catch (InvalidRequestException e) { if (e.getMessage().contains("doesn't exist")) { /* treat as already dropped */ } else throw e; }

Prevention

When it happens

Trigger: DROP INDEX ks.idx_name where the keyspace's table indexes have no entry for indexName (table lookup by index name returns null) and ifExists is false.

Common situations: Assuming index names equal column names (secondary indexes default to table_col_idx unless explicitly named); index already dropped; wrong keyspace.

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/b1435f3c9f6b9c2c. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/DropIndexStatement.java:72

        return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
    }

    @Override
    public Keyspaces apply(ClusterMetadata metadata)
    {
        Keyspaces schema = metadata.schema.getKeyspaces();
        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);

        TableMetadata table = null == keyspace
                            ? null
                            : keyspace.findIndexedTable(indexName).orElse(null);

        if (null == table)
        {
            if (ifExists)
                return schema;

            throw ire("Index '%s.%s' doesn't exist'", keyspaceName, indexName);
        }

        TableMetadata newTable = table.withSwapped(table.indexes.without(indexName));
        return schema.withAddedOrUpdated(keyspace.withSwapped(keyspace.tables.withSwapped(newTable)));
    }

    SchemaChange schemaChangeEvent(KeyspacesDiff diff)
    {
        assert diff.altered.size() == 1;
        KeyspaceDiff ksDiff = diff.altered.get(0);

        assert ksDiff.tables.altered.size() == 1;
        Diff.Altered<TableMetadata> tableDiff = ksDiff.tables.altered.iterator().next();

        return new SchemaChange(Change.UPDATED, Target.TABLE, keyspaceName, tableDiff.after.name);
    }

    public void authorize(ClientState client)

View on GitHub (pinned to 88fd0f6a0e)