inline_outer Funzione generatore con valori di tabella

Si applica a:check marked yes Databricks SQL check marked yes Databricks Runtime

Esplode una matrice di struct in una tabella con OUTER semantica.

Sintassi

inline_outer(expr)

Argomenti

  • expr: espressione ARRAY < STRUCT > .

Set di righe composte dai campi negli elementi struct della matrice expr. Le colonne generate da inline sono i nomi dei campi.

Se expr è NULL una singola riga con NULLs per ogni colonna viene generata.

  • Si applica a:check marked yes Databricks Runtime 12.1 e versioni precedenti:

    inline_outer può essere inserito nell'elenco SELECT solo come radice di un'espressione o dopo una VISUALIZZAZIONE LATERALE. Quando si inserisce la funzione nell'elenco SELECT non deve essere presente alcuna altra funzione generatore nello stesso SELECT elenco o UNSUPPORTED_GENERATOR. MULTI_GENERATOR viene generato.

  • Si applica a:check marked yes Databricks SQL check marked yes Databricks Runtime 12.2 e versioni successive:

    La chiamata dalla clausola LATERAL VIEW o dall'elenco SELECT è deprecata. Richiamare inline_outer invece come table_reference.

Esempi

Si applica a:check marked yes Databricks Runtime 12.1 e versioni precedenti:

> SELECT inline_outer(array(struct(1, 'a'), struct(2, 'b'))), 'Spark SQL';
 1  a Spark SQL
 2  b Spark SQL

> SELECT inline_outer(array(struct(1, 'a'), struct(1, 'b'))),
         inline_outer(array(struct('c', 1.0), struct('d', 2.0))),
         'Spark SQL';
 1  a Spark SQL
 2  b Spark SQL
Error: UNSUPPORTED_GENERATOR.MULTI_GENERATOR

Si applica a:check marked yes Databricks SQL check marked yes Databricks Runtime 12.2 e versioni successive:

> SELECT i.*, 'Spark SQL'
    FROM inline_outer(array(struct(1, 'a'), struct(2, 'b'))) AS i;
 1  a Spark SQL
 2  b Spark SQL

> SELECT i1.*, i2.*, 'Spark SQL'
   FROM  inline_outer(array(struct(1, 'a'), struct(1, 'b'))) AS i1,
         inline_outer(array(struct('c', 1.0), struct('d', 2.0))) AS i2;
 1      a       c       1.0     Spark SQL
 1      b       c       1.0     Spark SQL
 1      a       d       2.0     Spark SQL
 1      b       d       2.0     Spark SQL