prestodb/presto · error · SemanticException
MISSING_MATERIALIZED_VIEW
MISSING_MATERIALIZED_VIEW
Error message
Materialized view '%s' does not exist
What it means
Thrown by DropMaterializedViewTask.execute when the named materialized view has no definition registered with the metadata resolver and the statement lacks IF EXISTS. Note the task treats materialized views as both table and view for access checks, so this check happens before any permission verification.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/DropMaterializedViewTask.java:52
public class DropMaterializedViewTask
implements DDLDefinitionTask<DropMaterializedView>
{
@Override
public String getName()
{
return "DROP MATERIALIZED VIEW";
}
@Override
public ListenableFuture<?> execute(DropMaterializedView statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)
{
QualifiedObjectName name = createQualifiedObjectName(session, statement, statement.getName(), metadata);
Optional<MaterializedViewDefinition> view = metadata.getMetadataResolver(session).getMaterializedView(name);
if (!view.isPresent()) {
if (!statement.isExists()) {
throw new SemanticException(MISSING_MATERIALIZED_VIEW, statement, "Materialized view '%s' does not exist", name);
}
return immediateFuture(null);
}
accessControl.checkCanDropTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), name);
accessControl.checkCanDropView(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), name);
metadata.dropMaterializedView(session, name);
return immediateFuture(null);
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Confirm the materialized view exists: SHOW CREATE MATERIALIZED VIEW <name> or check system metadata.
- Use IF EXISTS: DROP MATERIALIZED VIEW IF EXISTS <name>.
- Verify you are targeting the correct catalog and schema, and that the object is actually a materialized view (not a table/view).
Example fix
// before DROP MATERIALIZED VIEW catalog.db.daily_agg; // after DROP MATERIALIZED VIEW IF EXISTS catalog.db.daily_agg;
Defensive patterns
Strategy: try-catch
Validate before calling
-- pre-check existence SELECT name FROM <catalog>.information_schema.views WHERE ...; -- or SHOW CREATE MATERIALIZED VIEW <name>
Try / catch
// JDBC client
try {
stmt.execute("DROP MATERIALIZED VIEW catalog.db.daily_agg");
} catch (SQLException e) {
if (e.getMessage() != null && e.getMessage().contains("does not exist")) {
// treat as success for idempotent cleanup
} else { throw e; }
} Prevention
- Use IF EXISTS for cleanup/teardown scripts.
- Confirm object type (table vs view vs materialized view) before choosing the DROP statement.
- Keep a registry of materialized view names owned by your pipelines.
When it happens
Trigger: DROP MATERIALIZED VIEW name where metadata.getMetadataResolver(session).getMaterializedView(name) returns empty and statement.isExists() is false.
Common situations: Typo in the view name; view already dropped; referencing a regular table or view with DROP MATERIALIZED VIEW; wrong catalog/schema; connector that does not implement materialized view metadata.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/c470045ff43ac641.
Report an issue: GitHub.