apache/cassandra · error · MaterializedViewNotFound
Materialized view '{}' not found
Error message
Materialized view '{}' not found What it means
Shell.get_view_meta looks up a materialized view in KeyspaceMetadata.views. If the view name is absent it raises MaterializedViewNotFound. Views are keyspace-scoped and live in their own metadata collection, separate from tables.
Source
Thrown at pylib/cqlshlib/cqlshmain.py:610
raise ColumnFamilyNotFound("Column family {} not found".format(tablename))
def get_index_meta(self, ksname, idxname):
if ksname is None:
ksname = self.current_keyspace
ksmeta = self.get_keyspace_meta(ksname)
if idxname not in ksmeta.indexes:
raise IndexNotFound("Index {} not found".format(idxname))
return ksmeta.indexes[idxname]
def get_view_meta(self, ksname, viewname):
if ksname is None:
ksname = self.current_keyspace
ksmeta = self.get_keyspace_meta(ksname)
if viewname not in ksmeta.views:
raise MaterializedViewNotFound("Materialized view '{}' not found".format(viewname))
return ksmeta.views[viewname]
def get_object_meta(self, ks, name):
if name is None:
if ks and ks in self.conn.metadata.keyspaces:
return self.conn.metadata.keyspaces[ks]
elif self.current_keyspace is None:
raise ObjectNotFound("'{}' not found in keyspaces".format(ks))
else:
name = ks
ks = self.current_keyspace
if ks is None:
ks = self.current_keyspace
ksmeta = self.get_keyspace_meta(ks)
if name in ksmeta.tables:View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Run DESCRIBE MATERIALIZED VIEWS (or DESCRIBE KEYSPACE) and correct the view name.
- Qualify the view with the correct keyspace.
- Refresh schema metadata / reconnect if the view was just created.
- Create the view with CREATE MATERIALIZED VIEW if it does not exist.
Example fix
// before
shell.get_view_meta('ks', 'user_by_email') # MaterializedViewNotFound
// after
shell.get_view_meta('ks', 'users_by_email') # exact view name Defensive patterns
Strategy: validation
Validate before calling
ksmeta = shell.get_keyspace_meta(ksname)
if viewname not in ksmeta.views:
raise LookupError(f"View {viewname} missing in {ksname}") Type guard
def view_exists(shell, ksname, viewname):
return viewname in shell.get_keyspace_meta(ksname).views Try / catch
try:
vmeta = shell.get_view_meta(ksname, viewname)
except MaterializedViewNotFound:
vmeta = None # fall back to table lookup or re-describe Prevention
- Confirm view names with DESCRIBE MATERIALIZED VIEWS.
- Keyspace-qualify view references.
- Refresh schema metadata after CREATE/DROP MATERIALIZED VIEW.
When it happens
Trigger: get_view_meta(ksname, viewname) with viewname not in ksmeta.views — commonly via parse_for_select_meta when a SELECT targets a materialized view that does not exist under that name/keyspace.
Common situations: Querying a view that was dropped; typo in the view name; view exists in a different keyspace; stale driver metadata right after CREATE MATERIALIZED VIEW.
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
- User type {!r} not found
- Keyspace %r not found.
- Column family {} not found
- Index {} not found
- '{}' not found in keyspace '{}'
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/b331f4fadd059cc2.
Report an issue: GitHub.