hasJsonSchema
Determine if a JSON object has specified keys.
Determine if a JSON object contains the list of specified fieldnames (keys).
Usage Details
select hasJsonSchema(column, listOfFieldnames) as resultCol from table
Input:
table: Input table.
column: Name of a column that contains JSON objects.
listOfFieldnames: Comma-separated list of fields, such as "key1, key2, key3".
Output:
true if the object contains the specified the field names; otherwise false.
Example
Input
| _raw |
|---|
| {"a":1, "b":2} |
| {"a":1, "c":3} |
select *, hasJsonSchema(_raw, "b, a") as resultCol from table
Output
| _raw | |
|---|---|
| {"a":1, "b":2} | true |
| {"a":1, "c":3} | false |
Updated about 2 years ago