json
Functions for parsing Mozilla-specific JSON data types.
extract_int_map (UDF)
Returns an array of key/value structs from a string representing a JSON map. Both keys and values are cast to integers.
This is the format for the "values" field in the desktop telemetry histogram JSON representation.
Parameters
INPUTS
input STRING
from_map (UDF)
Converts a standard "map" like datastructure array<struct<key, value>>
into a JSON value.
Convert the standard Array<Struct<key, value>>
style maps to JSON
values.
Parameters
INPUTS
input JSON
OUTPUTS
json
from_nested_map (UDF)
Converts a nested JSON object with repeated key/value pairs into a nested JSON object.
Convert a JSON object like { "metric": [ {"key": "extra", "value": 2 } ] }
to a JSON
object like { "metric": { "key": 2 } }
.
This only works on JSON types.
Parameters
OUTPUTS
json
js_extract_string_map (UDF)
Returns an array of key/value structs from a string representing a JSON map.
BigQuery Standard SQL JSON functions are insufficient to implement this function, so JS is being used and it may not perform well with large or numerous inputs.
Non-string non-null values are encoded as json.
Parameters
INPUTS
input STRING
OUTPUTS
ARRAY<STRUCT<key STRING, value STRING>>
mode_last (UDF)
Returns the most frequently occuring element in an array of json-compatible elements. In the case of multiple values tied for the highest count, it returns the value that appears latest in the array. Nulls are ignored.
Parameters
INPUTS
list ANY TYPE