Categories:

Context functions (Session Object)

CURRENT_ROLE¶

Returns the name of the primary role in use for the current session when the primary role is an account-level role or NULL if the role in use for the current session is a database role.

To specify a different role for the session, execute the USE ROLE command.

Syntax¶

CURRENT_ROLE()
Copy

Arguments¶

None.

Usage notes¶

  • Granting access on a secure UDF or secure view that contains this function to a share is allowed. When the secure UDF or secure view is accessed from the data sharing consumer account, this function always returns a NULL value.

  • Snowflake returns a NULL value if this function is used in a masking policy or row access policy that is assigned to a shared table or view.

Examples¶

This demonstrates CURRENT_ROLE():

SELECT CURRENT_ROLE();
Copy

Output:

+----------------+
| CURRENT_ROLE() |
|----------------|
| SYSADMIN       |
+----------------+
Copy