SET

Aplica-se a:check marked yes Databricks SQL check marked yes Databricks Runtime

Define um parâmetro do Azure Databricks no nível da sessão, retorna o valor de um parâmetro existente ou retorna todos os parâmetros com valor e significado. Ao usar o Databricks Runtime, os parâmetros são conhecidos como propriedades SQL Conf.

Para definir uma variável SQL, use SET VARIABLE.

Sintaxe

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

Parâmetros

  • (nenhum)

    Aplica-se a:check marked yes Databricks SQL

    Gera a chave e o valor dos parâmetros alterados do Azure Databricks.

  • -v

    Produz a chave, o valor e o significado dos parâmetros existentes.

  • parameter_key

    Retorna o valor do parâmetro especificado.

  • parameter_key = parameter_value

    Define o valor para um determinado parâmetro. Se existir um valor antigo para um determinado parâmetro, ele será substituído pelo novo valor.

Exemplos de SQL do Databricks

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

Exemplos de tempo de execução do 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