{"record":{"id":"6d9441f0ca55e74a","repo":"prestodb/presto","slug":"not-found-6d9441","errorCode":"NOT_FOUND","errorMessage":"Materialized view not found: ","messagePattern":"Materialized view not found: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/materializedview/IncrementalRefreshRule.java","lineNumber":135,"sourceCode":"    {\n        Session session = context.getSession();\n        PlanNodeIdAllocator idAllocator = context.getIdAllocator();\n        VariableAllocator variableAllocator = context.getVariableAllocator();\n\n        SchemaTableName materializedViewName = node.getMaterializedViewName();\n        TableHandle storageTableHandle = node.getStorageTableHandle();\n        String catalogName = storageTableHandle.getConnectorId().getCatalogName();\n\n        QualifiedObjectName qualifiedViewName = new QualifiedObjectName(\n                catalogName,\n                materializedViewName.getSchemaName(),\n                materializedViewName.getTableName());\n\n        MetadataResolver metadataResolver = metadata.getMetadataResolver(session);\n\n        Optional<MaterializedViewDefinition> materializedViewDefinition = metadataResolver.getMaterializedView(qualifiedViewName);\n        if (!materializedViewDefinition.isPresent()) {\n            throw new PrestoException(NOT_FOUND, \"Materialized view not found: \" + qualifiedViewName);\n        }\n\n        MaterializedViewRefreshType refreshType = materializedViewDefinition.get().getRefreshType()\n                .orElseGet(() -> getMaterializedViewDefaultRefreshType(session));\n        if (refreshType != MaterializedViewRefreshType.INCREMENTAL) {\n            return Result.ofPlanNode(node.getSource());\n        }\n\n        MaterializedViewStatus status = metadataResolver.getMaterializedViewStatus(qualifiedViewName, TupleDomain.all());\n\n        // If fully materialized, nothing to refresh - return empty result\n        if (status.isFullyMaterialized()) {\n            return Result.ofPlanNode(new ValuesNode(\n                    node.getSourceLocation(),\n                    idAllocator.getNextId(),\n                    node.getOutputVariables(),\n                    ImmutableList.of(),\n                    Optional.empty()));","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/materializedview/IncrementalRefreshRule.java#L117-L153","documentation":"The incremental materialized-view refresh rule resolves the view definition from metadata before planning the incremental refresh. If the referenced materialized view no longer exists in the catalog, it throws NOT_FOUND with the qualified view name.","triggerScenarios":"Querying a materialized view whose definition was dropped/renamed between planning steps, or when a stale plan/cache references a view that no longer resolves via metadata.getMaterializedView.","commonSituations":"Materialized view dropped while a query against it was in flight; typo'd schema/table in the name; connect privilege issues causing lookup to miss the view.","solutions":["Verify the materialized view exists: SHOW CREATE TABLE <catalog.schema.view>","Recreate the materialized view if it was dropped","Check the qualified name (catalog/schema/table) for typos or wrong catalog in the connection"],"exampleFix":"// before\nSELECT * FROM hive.sales.mv_daily_revenue; -- dropped\n// after\nCREATE MATERIALIZED VIEW hive.sales.mv_daily_revenue AS SELECT ...;\nSELECT * FROM hive.sales.mv_daily_revenue;","handlingStrategy":"validation","validationCode":"SELECT * FROM system.metadata.materialized_views WHERE name = '<view>'; -- check existence first","typeGuard":"null","tryCatchPattern":"try {\n    return query(\"SELECT * FROM mv\");\n} catch (PrestoException e) {\n    if (e.getErrorCode() == NOT_FOUND.toErrorCode()) {\n        recreateMaterializedView();\n        return retryQuery(\"SELECT * FROM mv\");\n    }\n    throw e;\n}","preventionTips":["Check view existence with metadata/system tables before querying","Avoid dropping materialized views while readers are active","Use stable, reviewed qualified names in application config"],"tags":["materialized-view","not-found","metadata"],"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-12T02:17:10.037Z"}