适用于:
Databricks SQL
Databricks Runtime 17.0 及更高版本
以 DDL 格式返回 Avro 模式的 JSON 格式模式。
Syntax
schema_of_avro(jsonFormatSchema [, options] )
Arguments
jsonFormatSchema:包含 JSON 格式的 Avro 架构的常量STRING表达式。options:包含转换选项的可选常量MAP<STRING, STRING>表达式。
Returns
STRING包含等效的 DDL 格式 SQL 模式。
选项
有关选项的完整列表,请参阅 Avro。
Examples
推导包含一个 Avro 记录的 SQL 模式:
> SELECT schema_of_avro(
'{"type":"record","name":"struct","fields":[{"name":"u","type":["int","string"]}]}');
STRUCT<u: STRUCT<member0: INT, member1: STRING> NOT NULL>