SYS_CONTEXT
functionsupportedAccounts, users, sessions, warehousesReturns information about the context in which the function is called.
Syntax
Syntax for retrieving properties
SYS_CONTEXT(
'<namespace>' ,
'<property>'
)
Syntax for calling functions
SYS_CONTEXT(
'<namespace>' ,
'<function>' , '<argument>' [ , ... ]
)
Parameters
| Name | Required | Description |
|---|---|---|
'namespace' | required | Namespace of the property that you want to retrieve or the function that you want to call. You can specify one of the following namespaces: Namespace Description SNOWFLAKE$APPLICATION Properties and functions providing context around the application in which the function is called. SNOWFLAKE$CURRENT Properties and functions providing context around the current execution context. The current execution context can differ from the session context inside owner’s rights executables or agent invocations. SNOWFLAKE$ENVIRONMENT Properties providing context around the environment in which the function is called. These properties include information about: The client, driver, or library that is used to call the function. The account associated with the session in which the function is called. The region of that account. SNOWFLAKE$ORGANIZATION Functions providing context around the current organization. SNOWFLAKE$ORGANIZATION_SESSION Properties providing context around the session in which the function is called, when the current account is in an organization. SNOWFLAKE$ORGANIZATION_SHARING Properties and functions providing consumer identity context for row access and masking policies on data shared within an organization. SNOWFLAKE$SESSION Properties and functions providing context around the session in which the function is called. SNOWFLAKE$SESSION_ATTRIBUTES Custom key-value attributes set for the current session using SET_SYS_CONTEXT.ExpandShow lessSee more |
'property' | required | Name of the property that you want to retrieve. The properties that you can specify depend on the namespace. See the documentation for a namespace for the list of properties that you can specify. |
'function' | required | Name of the function that you want to call. The functions that you can call depend on the namespace. See the documentation for a namespace for the list of functions that you can call. |
'argument' [ , ... ] | required | Arguments to pass to the function that you want to call. |
Returns
The function returns a value whose data type depends on the property that you are retrieving or the function that you are calling. Most properties and functions return a VARCHAR value or NULL. 2026_06 behavior change bundle When the 2026_06 behavior change bundle is enabled in your account, SYS_CONTEXT returns a value typed to match the property or function that you access instead of always returning VARCHAR. The following properties and functions return a typed value: All other properties and functions continue to return VARCHAR. Existing casts, such as ::BOOLEAN or ::NUMBER, continue to work unchanged. - The return value depends on the property that you are retrieving or the function that you are calling. See the documentation for each namespace for information about the properties and return values of functions in that namespace. - The function returns NULL if: The namespace is not accessible from within the context of the function call. For example, attempting to access properties in the SNOWFLAKE$APPLICATION namespace returns NULL if you are calling the function outside of application code. - The value of the property or the return value of the function call is NULL or non-existent. When SYS_CONTEXT returns VARCHAR (see the preceding note), Boolean-valued properties and functions return the string TRUE or FALSE. To compare this return value against the BOOLEAN value TRUE or FALSE, cast the return value to BOOLEAN. For example:
Usage notes
- See the documentation for each namespace for usage notes for the properties and functions in that namespace.
Access control requirements
See the documentation for each namespace for information about the access control requirements for the properties and functions in that namespace.
See also
- SYS_CONTEXT (SNOWFLAKE$APPLICATION namespace) ↗
- SYS_CONTEXT (SNOWFLAKE$CURRENT namespace) ↗
- SYS_CONTEXT (SNOWFLAKE$ENVIRONMENT namespace) ↗
- SYS_CONTEXT (SNOWFLAKE$ORGANIZATION namespace) ↗
- SYS_CONTEXT (SNOWFLAKE$ORGANIZATION_SESSION namespace) ↗
- SYS_CONTEXT (SNOWFLAKE$ORGANIZATION_SHARING namespace) ↗
- SYS_CONTEXT (SNOWFLAKE$SESSION namespace) ↗
- SYS_CONTEXT (SNOWFLAKE$SESSION_ATTRIBUTES namespace) ↗