Funzione schema_of_json

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

Restituisce lo schema di una JSON stringa in DDL formato .

Sintassi

schema_of_json(jsonStr [, options] )

Argomenti

  • jsonStrSTRING: espressione con una JSON stringa.
  • options: valori letterali facoltativi MAP con chiavi e valori.STRING

Resi

Oggetto STRING contenente una definizione di una matrice di struct con n campi di stringhe in cui i nomi delle colonne sono derivati dalle JSON chiavi. I valori dei campi contengono i tipi SQL formattati derivati. Per informazioni dettagliate sulle opzioni, vedere from_json funzione.

Esempi

> SELECT schema_of_json('[{"col":0}]');
 ARRAY<STRUCT<`col`: BIGINT>>

> SELECT schema_of_json('[{"col":01}]', map('allowNumericLeadingZeros', 'true'));
 ARRAY<STRUCT<`col`: BIGINT>>