{"record":{"id":"13f774a2ed355f16","repo":"prestodb/presto","slug":"materialized-view-not-found","errorCode":null,"errorMessage":"Materialized view not found","messagePattern":"Materialized view not found","errorType":"exception","errorClass":"MaterializedViewNotFoundException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java","lineNumber":2686,"sourceCode":"                    session,\n                    viewTable,\n                    principalPrivileges,\n                    Optional.empty(),\n                    ignoreExisting,\n                    new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of()),\n                    emptyList());\n        }\n        catch (TableAlreadyExistsException e) {\n            throw new MaterializedViewAlreadyExistsException(e.getTableName());\n        }\n    }\n\n    @Override\n    public void dropMaterializedView(ConnectorSession session, SchemaTableName viewName)\n    {\n        Optional<MaterializedViewDefinition> view = getMaterializedView(session, viewName);\n        if (!view.isPresent()) {\n            throw new MaterializedViewNotFoundException(viewName);\n        }\n\n        try {\n            metastore.dropTable(\n                    new HdfsContext(session, viewName.getSchemaName(), viewName.getTableName()),\n                    viewName.getSchemaName(),\n                    viewName.getTableName());\n        }\n        catch (TableNotFoundException e) {\n            throw new MaterializedViewNotFoundException(e.getTableName());\n        }\n    }\n\n    @Override\n    public HiveInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle)\n    {\n        return beginInsertInternal(session, tableHandle);\n    }","sourceCodeStart":2668,"sourceCodeEnd":2704,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java#L2668-L2704","documentation":"Thrown from dropMaterializedView when getMaterializedView finds no materialized view definition for the given name: the object does not exist, or exists but is not a Presto materialized view (no parseable materialized-view JSON in its metadata). MaterializedViewNotFoundException carries the SchemaTableName.","triggerScenarios":"DROP MATERIALIZED VIEW on a name that is a plain table or regular view, was already dropped, is misspelled, or exists in a different catalog/schema.","commonSituations":"Cleanup scripts running twice; confusing a plain table with a materialized view of the same name; catalog mix-ups (views created in another connector); objects dropped by other users.","solutions":["Use DROP MATERIALIZED VIEW IF EXISTS for idempotency","Verify the object type with SHOW TABLES / SHOW CREATE and use DROP TABLE or DROP VIEW if it is not a materialized view","Check catalog/schema spelling and current session catalog","If getMaterializedView keeps failing on a name you know is an MV, the stored definition is corrupt — see the INVALID_VIEW case and recreate the view"],"exampleFix":"-- before\nDROP MATERIALIZED VIEW metrics.mv_daily;\n-- after\nDROP MATERIALIZED VIEW IF EXISTS metrics.mv_daily;","handlingStrategy":"try-catch","validationCode":"-- existence and type check before drop\nSELECT * FROM system.metadata.table_comments\nWHERE schema_name = ? AND table_name = ?;\n-- or attempt getMaterializedView first and branch on isPresent()","typeGuard":null,"tryCatchPattern":"try {\n    run(\"DROP MATERIALIZED VIEW \" + name);\n} catch (MaterializedViewNotFoundException e) {\n    log.info(\"Materialized view absent, nothing to drop: {}\", name);\n}","preventionTips":["Use DROP MATERIALIZED VIEW IF EXISTS in cleanup scripts","Verify object kind before dropping (table vs view vs MV)","Qualify catalog and schema explicitly in automation","Guard against double-execution with IF EXISTS or state tracking"],"tags":["hive","materialized-view","not-found","ddl"],"backgroundTag":"object-not-found","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"}