Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime
Returns the schema of a JSON string in DDL format.
Syntax
schema_of_json(jsonStr [, options] )
Arguments
jsonStr: ASTRINGexpression with aJSONstring.options: An optionalMAPliterals with keys and values beingSTRING.
Returns
A STRING holding a definition of an array of structs with n fields of strings where the column names are derived from the JSON keys.
The field values hold the derived formatted SQL types.
For a complete list of options, see JSON.
To derive the aggregated schema of a group of JSON strings use the schema_of_json_agg aggregate function.
Examples
> SELECT schema_of_json('[{"col":0}]');
ARRAY<STRUCT<`col`: BIGINT>>
> SELECT schema_of_json('[{"col":01}]', map('allowNumericLeadingZeros', 'true'));
ARRAY<STRUCT<`col`: BIGINT>>