Categories:

Context functions (General)

SYS_CONTEXT (SNOWFLAKE$ENVIRONMENT namespace)¶

Returns information about the environment (the client, current account, and current region) in which the function is called.

See also:

SYS_CONTEXT , SYS_CONTEXT (SNOWFLAKE$APPLICATION namespace) , SYS_CONTEXT (SNOWFLAKE$ORGANIZATION namespace) , SYS_CONTEXT (SNOWFLAKE$ORGANIZATION_SESSION namespace) , SYS_CONTEXT (SNOWFLAKE$SESSION namespace)

Syntax¶

SYS_CONTEXT(
  'SNOWFLAKE$ENVIRONMENT' ,
  '<property>'
)
Copy

Arguments¶

'SNOWFLAKE$ENVIRONMENT'

Specifies that you want to retrieve a property to return context information about the environment in which the function is called.

'property'

Name of the property that you want to retrieve. You can specify the following properties:

Property

Description

CLIENT

Name and version of the client, driver, or library used to call the function.

If this function is called in Snowsight, the function returns the name and version of the Go Snowflake Driver.

If this function is called in Snowflake CLI, the function returns the name and version of the Snowflake Connector for Python.

The value of this property is the same as the return value of the CURRENT_CLIENT function.

ACCOUNT

The account locator of the account for the current session.

The value of this property is the same as the return value of the CURRENT_ACCOUNT function.

REGION

The name of the region of the account for the current session.

For organizations that have accounts in multiple region groups, the value of the property is region_group.region.

The value of this property is the same as the return value of the CURRENT_REGION function.

Returns¶

The function returns a VARCHAR value.

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 $ENVIRONMENT is 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:

    snow sql --query "SELECT SYS_CONTEXT('SNOWFLAKE\$ENVIRONMENT', 'CLIENT');"
    
    Copy

Examples¶

The following example returns the name and version of the client used to execute the command:

SELECT SYS_CONTEXT('SNOWFLAKE$ENVIRONMENT', 'CLIENT');
Copy

The following example returns the account locator of the account for the current session:

SELECT SYS_CONTEXT('SNOWFLAKE$ENVIRONMENT', 'ACCOUNT');
Copy

The following example returns the region of the account for the current session:

SELECT SYS_CONTEXT('SNOWFLAKE$ENVIRONMENT', 'REGION');
Copy