prestodb/presto · error · ViewNotFoundException

View not found

Error message

View not found

What it means

Mapped from TableNotFoundException when DROP VIEW cannot find the named object: the connector delegates to metastore.dropTable and translates the missing-table error into ViewNotFoundException. It means no Presto view with that schema.table name exists in the metastore.

Solutions

  1. Use DROP VIEW IF EXISTS to make the statement idempotent
  2. Verify the exact name with SHOW TABLES / system metadata or listViews
  3. Confirm you are connected to the right catalog and schema
  4. If a plain table with that name exists, use DROP TABLE instead of DROP VIEW

Example fix

-- before
DROP VIEW analytics.daily_revenue;
-- after
DROP VIEW IF EXISTS analytics.daily_revenue;
Defensive patterns

Strategy: try-catch

Try / catch

try {
    run("DROP VIEW " + name);
} catch (ViewNotFoundException e) {
    // already gone — fine for cleanup scripts
    log.info("View absent, skipping: {}", name);
}

Prevention

When it happens

Trigger: DROP VIEW on a name that was never created, was already dropped, exists only as a plain Hive table (not a view), or whose schema is misspelled/points at the wrong catalog.

Common situations: Non-idempotent cleanup scripts dropping views twice; typo in schema or view name; querying the wrong catalog (e.g. hive vs iceberg) where the view does not exist; views dropped by another team member.

Related errors


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

Appendix: source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java:2504

        catch (TableAlreadyExistsException e) {
            throw new ViewAlreadyExistsException(e.getTableName());
        }
    }

    @Override
    public void dropView(ConnectorSession session, SchemaTableName viewName)
    {
        ConnectorViewDefinition view = getViews(session, viewName.toSchemaTablePrefix()).get(viewName);
        checkIfNullView(view, viewName);

        try {
            metastore.dropTable(
                    new HdfsContext(session, viewName.getSchemaName()),
                    viewName.getSchemaName(),
                    viewName.getTableName());
        }
        catch (TableNotFoundException e) {
            throw new ViewNotFoundException(e.getTableName());
        }
    }

    @Override
    public List<SchemaTableName> listViews(ConnectorSession session, String schemaNameOrNull)
    {
        ImmutableList.Builder<SchemaTableName> tableNames = ImmutableList.builder();
        MetastoreContext metastoreContext = getMetastoreContext(session);
        for (String schemaName : listSchemas(session, schemaNameOrNull)) {
            for (String tableName : metastore.getAllViews(metastoreContext, schemaName).orElse(emptyList())) {
                tableNames.add(new SchemaTableName(schemaName, tableName));
            }
        }
        return tableNames.build();
    }

    @Override
    public Map<SchemaTableName, ConnectorViewDefinition> getViews(ConnectorSession session, SchemaTablePrefix prefix)

View on GitHub (pinned to 55bb57d202)