prestodb/presto · error · AccessDeniedException

Cannot rename view from %s to %s%s

Error message

Cannot rename view from %s to %s%s

What it means

Thrown when the identity lacks the RENAME_VIEW (ownership) privilege on a view. The connector authorizer calls denyRenameView during checkCanRenameView, rejecting ALTER VIEW ... RENAME. Only the view owner or an authorized principal may rename it.

Source

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

    public static void denyCreateViewWithSelect(String sourceName, ConnectorIdentity identity)
    {
        denyCreateViewWithSelect(sourceName, identity, null);
    }

    public static void denyCreateViewWithSelect(String sourceName, ConnectorIdentity identity, String extraInfo)
    {
        throw new AccessDeniedException(format("View owner '%s' cannot create view that selects from %s%s", identity.getUser(), sourceName, formatExtraInfo(extraInfo)));
    }

    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)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Run the rename as the view's owner or an admin
  2. Set the view owner to the requesting principal (e.g. ALTER VIEW ... SET AUTHORIZATION)
  3. Adjust the access control rules to grant RENAME_VIEW

Example fix

// before
ALTER VIEW analytics.daily RENAME TO analytics.daily_v2; -- AccessDeniedException
// after (as owner/admin or after)
ALTER VIEW analytics.daily SET AUTHORIZATION bob;
ALTER VIEW analytics.daily RENAME TO analytics.daily_v2;
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm requester is the view owner before attempting rename
boolean isOwner = viewOwner.equals(requestingUser) || catalogAdmin.isAdmin(requestingUser);

Try / catch

try {
    execute("ALTER VIEW " + oldName + " RENAME TO " + newName);
} catch (AccessDeniedException e) {
    throw new SecurityException("Only the view owner may rename " + oldName, e);
}

Prevention

When it happens

Trigger: ALTER VIEW old RENAME TO new where AccessControlManager.checkCanRenameView is denied for the current identity.

Common situations: Non-owner attempting rename; ownership transferred after original creator left; connectors that never grant rename to non-admins.

Related errors


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