apache/cassandra · error · InvalidRequestException
Materialized view ' . ' doesn't exist
Error message
Materialized view '%s.%s' doesn't exist
What it means
Existence guard in DropViewStatement.apply(): the materialized view named in DROP MATERIALIZED VIEW cannot be resolved — the keyspace is missing or keyspace.views has no entry for viewName. Unless IF EXISTS is given, the statement fails with InvalidRequestException naming the nonexistent view.
Solutions
- Add IF EXISTS to make the drop idempotent; verify the view name and keyspace with DESCRIBE MATERIALIZED VIEWS; check whether the view was already dropped or is a plain table sharing the name.
Example fix
// before DROP MATERIALIZED VIEW ks.metrics; // after DROP MATERIALIZED VIEW IF EXISTS ks.metrics_by_day;
Defensive patterns
Strategy: validation
Validate before calling
var exists = session.execute("SELECT view_name FROM system_schema.views WHERE keyspace_name=? AND view_name=?", ks, view).iterator().hasNext();
if (exists) session.execute("DROP MATERIALIZED VIEW IF EXISTS " + ks + "." + view); Try / catch
try { session.execute(ddl); } catch (InvalidRequest e) { if (e.getMessage().contains("doesn't exist")) log.info("View already absent"); else throw e; } Prevention
- Always use the view name, not the base table name
- Use IF EXISTS in cleanup scripts
- List views with system_schema.views before drops
When it happens
Trigger: Executing DROP MATERIALIZED VIEW <ks>.<view> when keyspace.views has no entry with that name; typo in view name; script re-run after the view was already dropped; using a table name instead of the view name.
Common situations: Confusing base table names with view names; typos; running cleanup twice; environments where the view was never created.
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
- Cannot drop a table when materialized views still depend on…
- ACCESS TO DATACENTERS operations not supported by…
- Altering column types is no longer supported
- Cannot add a counter column to Accord table
- Cannot add new column to a COMPACT STORAGE table
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/9ad14d6dd1f1d297.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/schema/DropViewStatement.java:70
return metadata.directory.commonSerializationVersion.isAtLeast(Version.V0);
}
@Override
public Keyspaces apply(ClusterMetadata metadata)
{
Keyspaces schema = metadata.schema.getKeyspaces();
KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
ViewMetadata view = null == keyspace
? null
: keyspace.views.getNullable(viewName);
if (null == view)
{
if (ifExists)
return schema;
throw ire("Materialized view '%s.%s' doesn't exist", keyspaceName, viewName);
}
return schema.withAddedOrUpdated(keyspace.withSwapped(keyspace.views.without(viewName)));
}
SchemaChange schemaChangeEvent(KeyspacesDiff diff)
{
return new SchemaChange(Change.DROPPED, Target.TABLE, keyspaceName, viewName);
}
public void authorize(ClientState client)
{
ViewMetadata view = Schema.instance.getView(keyspaceName, viewName);
if (null != view)
client.ensureTablePermission(keyspaceName, view.baseTableName, Permission.ALTER);
}
@OverrideView on GitHub (pinned to 88fd0f6a0e)