snowflake-cloud-data-platform

Change a Procedure but keep the priviliges


in Snowflake you can't really ALTER a procedure. All you can do with an ALTER is renaming or changing the comment.

The problem I face is that sometimes I have to change a stored procedure in Snowflake. I have to do this with a CREATE OR REPLACE. But with a CREATE OR REPLACE I lose all current GRANTS on the procedure. It happened a few times that loading processes failed, because the day prior I changed a procedure and forgot the grant the USAGE right to the staging-User.

Is there an easy solution for this? Can I somehow CREATE OR REPLACE a procedure and keep the current USAGE-grants?


Solution

  • Since, for any change to the definition of the stored procedure, it is a security best practice to validate the access privileges. Hence, with every change, you need to re-grant the privilege.

    You may use the below show statement for the stored procedure and capture the grants and reapply them after the change

    SHOW GRANTS ON <object_type> <object_name>