schema_of_avro function
Applies to: Databricks SQL
Databricks Runtime 17.0 and above
Returns the schema of an Avro schema in JSON format as a DDL-formatted string.
Syntax
schema_of_avro(jsonFormatSchema [, options] )
Arguments
jsonFormatSchema: A constantSTRINGexpression containing an Avro schema in JSON format.options: An optional constantMAP<STRING, STRING>expression containing conversion options.
Returns
A STRING containing the equivalent SQL schema in DDL format.
Options
For a complete list of options, see Avro.
Examples
Derive the SQL schema for an Avro record containing a union:
SQL
> SELECT schema_of_avro(
'{"type":"record","name":"struct","fields":[{"name":"u","type":["int","string"]}]}');
STRUCT<u: STRUCT<member0: INT, member1: STRING> NOT NULL>