- Categories:
Context functions (General)
IS_ ROLE_ ACTIVATED (SYS_ CONTEXT function)¶
Returns the VARCHAR value 'TRUE' if an account role is activated. You can check one role or several roles in a single call,
and you can check activation in the session context or in the current execution context.
Syntax¶
Check role activation in the session:
Check role activation in the current execution context:
Arguments¶
'SNOWFLAKE$SESSION'Specifies that you want to check role activation in the session context.
'SNOWFLAKE$CURRENT'Specifies that you want to check role activation in the current execution context. The current execution context can differ from the session context inside an owner’s rights executable or during an agent invocation. For more information, see SYS_CONTEXT (SNOWFLAKE$CURRENT namespace).
'IS_ROLE_ACTIVATED'Calls the IS_ROLE_ACTIVATED function.
'role' [ , 'role' ... ]Specifies the account role or roles to check. You can pass one role or several roles as separate arguments. The function returns
'TRUE'if any of the specified roles is activated. Multiple roles must be constant values (see the usage notes).
Returns¶
The function returns one of the following VARCHAR values:
'TRUE'if any of the specified account roles is activated in the specified context.'FALSE'if none of the specified account roles is activated, or if none of the specified roles exists.
To compare this return value against the BOOLEAN value TRUE or FALSE, cast the return value to BOOLEAN. For example:
2026_06 behavior change bundle
When the 2026_06 behavior change bundle is enabled in your account, when you call this
function through SYS_CONTEXT, it returns BOOLEAN instead of the VARCHAR
string 'TRUE' or 'FALSE'.
Existing casts, such as ::BOOLEAN or ::NUMBER, continue to work unchanged.
For the return type of every property and function by namespace, see SYS_CONTEXT return types.
Usage notes¶
-
When you use the SNOWFLAKE$SESSION namespace, the function checks whether the role is in the role hierarchy of the session’s primary or secondary roles.
-
When you use the SNOWFLAKE$CURRENT namespace, the function checks the innermost execution context. Inside an owner’s rights stored procedure, for example, this reflects the owner’s activated roles, not the caller’s.
-
When you specify more than one role, the function returns
'TRUE'if any of the roles is activated. Snowflake ignores duplicate role names. -
You can specify multiple roles only when each role is a constant value, such as a string literal. When the role is an expression that isn’t a constant, such as a column reference in a row access policy, you can specify only a single role.
-
To simulate the result of this function in a policy, use the
SNOWFLAKE$SESSION_ACTIVATED_ROLESorSNOWFLAKE$CURRENT_ACTIVATED_ROLESlist argument with the POLICY_CONTEXT function.
Examples¶
The following example returns 'TRUE' if the role my_role is in the role hierarchy of the session’s primary or secondary
roles:
The following example checks whether the role analyst is activated in the current execution context:
The following example checks several roles in a single call. It returns 'TRUE' if any of the roles analyst, auditor, or
reviewer is activated in the session: