Categories:

Context functions (General)

SYS_CONTEXT(SNOWFLAKE$ENVIRONMENT 命名空间)

返回有关调用该函数的环境(客户端、当前账户和当前区域)的信息。

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)

语法

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

实参

'SNOWFLAKE$ENVIRONMENT'

指定您要检索一个属性,以返回有关调用函数的环境的上下文信息。

'property'

要检索的属性的名称。您可以指定以下属性:

PropertyDescription
CLIENT

用于调用该函数的客户端、驱动程序或库的名称和版本。

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.

返回

该函数会返回 VARCHAR 值。

使用说明

  • 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');"

示例

以下示例返回用于执行命令的客户端名称和版本:

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

以下示例返回当前会话所属账户的账户定位器:

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

以下示例返回当前会话所属账户的区域:

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