Skip to main content

schema_of_avro function

Applies to: check marked yes Databricks SQL check marked yes 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 constant STRING expression containing an Avro schema in JSON format.
  • options: An optional constant MAP<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>