- Categories:
Context functions (General)
SYS_ CONTEXT (SNOWFLAKE$APPLICATION namespace)¶
Returns information about the context in which a statement is executed within a Snowflake Native App.
You can call this function in the following contexts:
- A stored procedure or Streamlit app that is configured to use owner’s rights and is within or owned by a Snowflake Native App.
- A UDF, view, or policy that is owned by a Snowflake Native App.
- A UDF, view, or policy that is part of the shared data content of a Snowflake Native App.
In any other context, the function returns NULL.
Syntax¶
Syntax for retrieving properties:
Syntax for calling functions:
Arguments¶
'SNOWFLAKE$APPLICATION'Specifies that you want to retrieve a property or call a function to return context information about the application in which the function is called.
'property'Name of the property that you want to retrieve. You can specify the following properties:
Property Description NAMEName of the application. CURRENT_VERSIONCurrent version of the application in which the current SQL statement is executed.
The value of the
CURRENT_VERSIONproperty can differ from theINSTALLED_VERSIONproperty in the following situations:- The SQL statement is executed in a setup script that upgrades the application to a new version.
In this case,
CURRENT_VERSIONis the new version, andINSTALLED_VERSIONis the currently installed version that is being upgraded.- A long-running procedure or query started executing before an upgrade completed.
In this case,
CURRENT_VERSIONis the version when the procedure or query started executing, andINSTALLED_VERSIONis the version after the upgrade completed.CURRENT_PATCHCurrent patch number of the application in which the current SQL statement is executed. INSTALLED_VERSIONInstalled version of the application in which the current SQL statement is executed. INSTALLED_PATCHInstalled patch number of the application in which the current SQL statement is executed. IS_DEV_MODETRUEif the application is in development mode; otherwise,FALSE.To compare this value against the BOOLEAN value TRUE or FALSE, cast the value to BOOLEAN. For example:
Returns¶
The function returns a VARCHAR value or NULL:
- The return value depends on the property that you are retrieving or the function that you are calling.
- If you call SYS_CONTEXT with the SNOWFLAKE$APPLICATION namespace outside of any of the supported contexts, the function returns NULL.
Usage notes¶
-
If you are specifying the function call in a double-quoted string in a shell, escape the
$character with a backslash (\) so that$APPLICATIONis not interpreted as a shell variable.For example, if you are using Snowflake CLI and you are specifying the SQL statement as a command-line argument in double quotes:
Examples¶
The following example returns the current version of the application: