SET

適用于: check marked yes Databricks SQL check marked yes Databricks Runtime

在工作階段層級設定 Azure Databricks 參數 、傳回現有參數的值,或傳回具有值和意義的所有參數。 使用 Databricks Runtime 時,參數稱為 SQL Conf 屬性。

若要設定 SQL 變數 請使用 SET VARIABLE

語法

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

參數

  • (無)

    適用于: 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 執行時間範例

-- 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