prestodb/presto · error · PrestoException

VIEW_NOT_FOUND

VIEW_NOT_FOUND

Error message

View %s not found, the available view names are: %s

What it means

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.

Source

Thrown at presto-analyzer/src/main/java/com/facebook/presto/sql/analyzer/MetadataHandle.java:67

    public void addViewDefinition(QualifiedObjectName viewName, Future<Optional<ViewDefinition>> viewDefinition)
    {
        this.viewDefinitions.putIfAbsent(viewName, viewDefinition);
    }

    public void addMaterializedViewDefinition(QualifiedObjectName viewName, Future<Optional<MaterializedViewDefinition>> viewDefinition)
    {
        this.materializedViewDefinitions.putIfAbsent(viewName, viewDefinition);
    }

    public void addTableColumnMetadata(QualifiedObjectName tableName, Future<TableColumnMetadata> tableColumnMetadata)
    {
        this.tableColumnsMetadata.putIfAbsent(tableName, tableColumnMetadata);
    }

    public Optional<ViewDefinition> getViewDefinition(QualifiedObjectName viewName)
    {
        if (!viewDefinitions.containsKey(viewName)) {
            throw new PrestoException(VIEW_NOT_FOUND, format("View %s not found, the available view names are: %s", viewName, viewDefinitions.keySet()));
        }

        try {
            return viewDefinitions.get(viewName).get();
        }
        catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(ex);
        }
        catch (ExecutionException ex) {
            throwIfUnchecked(ex.getCause());
            throw new RuntimeException(ex.getCause());
        }
    }

    public Optional<MaterializedViewDefinition> getMaterializedViewDefinition(QualifiedObjectName viewName)
    {
        checkState(materializedViewDefinitions.containsKey(viewName), "View " + viewName + " not found");

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the view exists (SELECT from information_schema.views or SHOW CREATE VIEW) and recreate it if dropped
  2. Refresh/clear the metadata cache so viewDefinitions is repopulated
  3. Ensure the exact catalog.schema.view name matches (case/qualifiers) what exists
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check view existence via system tables
SELECT table_name FROM information_schema.views WHERE table_schema = 'myschema' AND table_name = 'myview';

Try / catch

try { ViewDefinition def = handle.getViewDefinition(viewName); } catch (PrestoException e) { if (e.getErrorCode().getName().equals("VIEW_NOT_FOUND")) { /* recreate/refresh view or cache */ } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: View dropped or renamed while a query using it is analyzed; connector returning stale view listings; custom plugins calling getViewDefinition with names not preloaded.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/ac00ce01ac14edf3. Report an issue: GitHub.