{"record":{"id":"ac00ce01ac14edf3","repo":"prestodb/presto","slug":"view-not-found","errorCode":"VIEW_NOT_FOUND","errorMessage":"View %s not found, the available view names are: %s","messagePattern":"View (.+?) not found, the available view names are: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-analyzer/src/main/java/com/facebook/presto/sql/analyzer/MetadataHandle.java","lineNumber":67,"sourceCode":"    public void addViewDefinition(QualifiedObjectName viewName, Future<Optional<ViewDefinition>> viewDefinition)\n    {\n        this.viewDefinitions.putIfAbsent(viewName, viewDefinition);\n    }\n\n    public void addMaterializedViewDefinition(QualifiedObjectName viewName, Future<Optional<MaterializedViewDefinition>> viewDefinition)\n    {\n        this.materializedViewDefinitions.putIfAbsent(viewName, viewDefinition);\n    }\n\n    public void addTableColumnMetadata(QualifiedObjectName tableName, Future<TableColumnMetadata> tableColumnMetadata)\n    {\n        this.tableColumnsMetadata.putIfAbsent(tableName, tableColumnMetadata);\n    }\n\n    public Optional<ViewDefinition> getViewDefinition(QualifiedObjectName viewName)\n    {\n        if (!viewDefinitions.containsKey(viewName)) {\n            throw new PrestoException(VIEW_NOT_FOUND, format(\"View %s not found, the available view names are: %s\", viewName, viewDefinitions.keySet()));\n        }\n\n        try {\n            return viewDefinitions.get(viewName).get();\n        }\n        catch (InterruptedException ex) {\n            Thread.currentThread().interrupt();\n            throw new RuntimeException(ex);\n        }\n        catch (ExecutionException ex) {\n            throwIfUnchecked(ex.getCause());\n            throw new RuntimeException(ex.getCause());\n        }\n    }\n\n    public Optional<MaterializedViewDefinition> getMaterializedViewDefinition(QualifiedObjectName viewName)\n    {\n        checkState(materializedViewDefinitions.containsKey(viewName), \"View \" + viewName + \" not found\");","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-analyzer/src/main/java/com/facebook/presto/sql/analyzer/MetadataHandle.java#L49-L85","documentation":"MetadataHandle caches view definitions. getViewDefinition is only called for views already registered in its cache; if the requested QualifiedObjectName is absent from viewDefinitions it throws this PrestoException. It indicates a view metadata lookup for a name that the analyzer was told exists but for which no definition was captured.","triggerScenarios":"Calling MetadataHandle.getViewDefinition (directly or via the overload) with a QualifiedObjectName that was never populated into the handle; a race where a view is dropped between listing and definition fetch; stale catalog/cache state.","commonSituations":"View dropped or renamed while a query using it is analyzed; connector returning stale view listings; custom plugins calling getViewDefinition with names not preloaded.","solutions":["Verify the view exists (SELECT from information_schema.views or SHOW CREATE VIEW) and recreate it if dropped","Refresh/clear the metadata cache so viewDefinitions is repopulated","Ensure the exact catalog.schema.view name matches (case/qualifiers) what exists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check view existence via system tables\nSELECT table_name FROM information_schema.views WHERE table_schema = 'myschema' AND table_name = 'myview';","typeGuard":null,"tryCatchPattern":"try { ViewDefinition def = handle.getViewDefinition(viewName); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"VIEW_NOT_FOUND\")) { /* recreate/refresh view or cache */ } throw e; }","preventionTips":["Confirm the view exists before querying (SHOW CREATE VIEW)","Recreate views atomically (CREATE OR REPLACE) to avoid drop/analyze races","Keep catalog metadata caches consistent after DDL"],"tags":["views","metadata","catalog"],"backgroundTag":"view-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"}