Skip to content

bigfunctions > json_schema

json_schema

Signature

json_schema(json_string)

Description

Return the schema of a json string as [{path, type}] with path the path of the nested field and type among (string, numeric, bool, date, timestamp)

Examples

select bigfunctions.eu.json_schema('{"created_at": "2022-01-01", "user": {"name": "James", "friends": ["Jack", "Peter"]}}')
select bigfunctions.us.json_schema('{"created_at": "2022-01-01", "user": {"name": "James", "friends": ["Jack", "Peter"]}}')
select bigfunctions.europe_west1.json_schema('{"created_at": "2022-01-01", "user": {"name": "James", "friends": ["Jack", "Peter"]}}')
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| schema                                                                                                                                                          |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [
|   struct("created_at" as path, "date" as type),
|   struct("user.name" as path, "string" as type),
|   struct("user.friends" as path, "array" as type)
| ]
 |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+