prestodb/presto · error · AccessDeniedException

Cannot drop view

Error message

Cannot drop view %s%s

What it means

Thrown when the identity lacks the DROP_VIEW privilege on a view. denyDropView is invoked from AccessControlManager.checkCanDropView when the connector authorizer rejects the operation. View drops are typically restricted to owners/admins.

Solutions

  1. Run DROP VIEW as the view owner or an admin
  2. Change view ownership to the requesting principal (SET AUTHORIZATION)
  3. Grant DROP_VIEW privilege in the access control configuration

Example fix

// before
DROP VIEW analytics.daily; -- AccessDeniedException
// after (as admin)
ALTER VIEW analytics.daily SET AUTHORIZATION cleanup_svc;
-- run DROP VIEW as cleanup_svc
Defensive patterns

Strategy: try-catch

Validate before calling

boolean canDrop = viewOwner.equals(requestingUser) || catalogAdmin.userHasPrivilege(requestingUser, view, "DROP");

Try / catch

try {
    execute("DROP VIEW " + viewName);
} catch (AccessDeniedException e) {
    log.error("DROP VIEW denied for {}: {}", currentUser, e.getMessage());
    throw new SecurityException("Request DROP VIEW via the view owner or an admin", e);
}

Prevention

When it happens

Trigger: DROP VIEW <name> where checkCanDropView dispatches to the authorizer and denies the current identity.

Common situations: Cleanup scripts run by a service account without ownership; views created by departed employees; strict access-control configs requiring explicit DROP grants.

Related errors


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

Appendix: source

Thrown at presto-spi/src/main/java/com/facebook/presto/spi/security/AccessDeniedException.java:302

    public static void denyRenameView(String viewName, String newViewName)
    {
        denyRenameView(viewName, newViewName, null);
    }

    public static void denyRenameView(String viewName, String newViewName, String extraInfo)
    {
        throw new AccessDeniedException(format("Cannot rename view from %s to %s%s", viewName, newViewName, formatExtraInfo(extraInfo)));
    }

    public static void denyDropView(String viewName)
    {
        denyDropView(viewName, null);
    }

    public static void denyDropView(String viewName, String extraInfo)
    {
        throw new AccessDeniedException(format("Cannot drop view %s%s", viewName, formatExtraInfo(extraInfo)));
    }

    public static void denySelectView(String viewName)
    {
        denySelectView(viewName, null);
    }

    public static void denySelectView(String viewName, String extraInfo)
    {
        throw new AccessDeniedException(format("Cannot select from view %s%s", viewName, formatExtraInfo(extraInfo)));
    }

    public static void denyGrantTablePrivilege(String privilege, String tableName)
    {
        denyGrantTablePrivilege(privilege, tableName, null);
    }

    public static void denyGrantTablePrivilege(String privilege, String tableName, String extraInfo)

View on GitHub (pinned to 55bb57d202)