{"record":{"id":"c470045ff43ac641","repo":"prestodb/presto","slug":"missing-materialized-view","errorCode":"MISSING_MATERIALIZED_VIEW","errorMessage":"Materialized view '%s' does not exist","messagePattern":"Materialized view '(.+?)' does not exist","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/DropMaterializedViewTask.java","lineNumber":52,"sourceCode":"\npublic class DropMaterializedViewTask\n        implements DDLDefinitionTask<DropMaterializedView>\n{\n    @Override\n    public String getName()\n    {\n        return \"DROP MATERIALIZED VIEW\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(DropMaterializedView statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        QualifiedObjectName name = createQualifiedObjectName(session, statement, statement.getName(), metadata);\n\n        Optional<MaterializedViewDefinition> view = metadata.getMetadataResolver(session).getMaterializedView(name);\n        if (!view.isPresent()) {\n            if (!statement.isExists()) {\n                throw new SemanticException(MISSING_MATERIALIZED_VIEW, statement, \"Materialized view '%s' does not exist\", name);\n            }\n            return immediateFuture(null);\n        }\n\n        accessControl.checkCanDropTable(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), name);\n        accessControl.checkCanDropView(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), name);\n\n        metadata.dropMaterializedView(session, name);\n\n        return immediateFuture(null);\n    }\n}\n","sourceCodeStart":34,"sourceCodeEnd":65,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropMaterializedViewTask.java#L34-L65","documentation":"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.","triggerScenarios":"DROP MATERIALIZED VIEW name where metadata.getMetadataResolver(session).getMaterializedView(name) returns empty and statement.isExists() is false.","commonSituations":"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.","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)."],"exampleFix":"// before\nDROP MATERIALIZED VIEW catalog.db.daily_agg;\n// after\nDROP MATERIALIZED VIEW IF EXISTS catalog.db.daily_agg;","handlingStrategy":"try-catch","validationCode":"-- pre-check existence\nSELECT name FROM <catalog>.information_schema.views\nWHERE ...; -- or SHOW CREATE MATERIALIZED VIEW <name>","typeGuard":null,"tryCatchPattern":"// JDBC client\ntry {\n  stmt.execute(\"DROP MATERIALIZED VIEW catalog.db.daily_agg\");\n} catch (SQLException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"does not exist\")) {\n    // treat as success for idempotent cleanup\n  } else { throw e; }\n}","preventionTips":["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."],"tags":["sql","materialized-view","missing-object"],"backgroundTag":"materialized-view-does-not-exist","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}