SET

适用于:Databricks SQL check marked yes Databricks Runtime

在会话级别设置 Azure Databricks 参数,返回现有参数的值,或返回具有值和含义的所有参数。 使用 Databricks Runtime 时,参数称为 SQL Conf 属性。

若要设置 SQL 变量,请使用 SET VARIABLE

语法

SET
SET [ -v ]
SET parameter_key [ = parameter_value ]

参数

  • (none)

    适用于:check marked yes Databricks SQL

    输出已更改 Azure Databricks 参数的键和值。

  • -v

    输出现有参数的键、值和含义。

  • parameter_key

    返回指定参数的值。

  • parameter_key = parameter_value

    设置给定参数的值。 如果给定参数存在旧值,则新值将替代该值。

Databricks SQL 示例

-- Set a property.
> SET ansi_mode = true;

-- List all configuration parameters with their value and description.
> SET -v;

-- List all configuration parameters with a set value for the current session.
> SET;

-- List the value of specified property key.
> SET ansi_mode;
  key        value
  --------- -----
  ansi_mode  true

-- Use SET VARIABLE to set SQL variables
> DECLARE var INT;
> SET var = 5;
Error: UNSUPPORTED_FEATURE.SET_VARIABLE_USING_SET
> SET VAR var = 5;
> SELECT var;
  5

Databricks Runtime 示例

-- Set a property.
> SET spark.sql.variable.substitute=false;

-- List all SQLConf properties with value and meaning.
> SET -v;

-- List all SQLConf properties with value for current session.
> SET;

-- List the value of specified property key.
> SET spark.sql.variable.substitute;
                           key value
 ----------------------------- -----
 spark.sql.variable.substitute false