module pixeltable.functions.json
Pixeltable UDFs forJsonType.
Example:
iterator list_iterator()
Signature
- If a single positional argument is specified, as in
list_iterator(t.col), then the elements oft.colmust contain lists of dictionaries with matching signatures (identical keys and compatible value types). The iterator will yield one new column for each key in the dictionaries, and one output row per element in the lists. - If multiple keyword arguments are specified, as in
list_iterator(val_1=t.col_1, val_2=t.col_2), then the elements of each input column must contain lists, but not necessarily lists of dictionaries. The iterator will yield one new column for each keyword argument, zipping together the individual lists.
Json expressions. Untyped Json will be rejected (the type schema is
necessary in order for Pixeltable to determine the types of the output columns).
Parameters:
elements(pxt.Json[(Json): A list of dictionaries to iterate over. The dictionary keys will be used as column names in the output. Cannot be specified together with keyword arguments.mode(Any): Only applies when called with keyword arguments. Determines how to handle lists of different lengths:'strict': Raises an error if the input lists have different lengths.'truncated': Iterates until the shortest input list is exhausted, ignoring any remaining elements in longer lists.'padded': Iterates until the longest input list is exhausted, yieldingNonefor any missing elements from shorter lists.
**kwargs(Any): One or more lists to iterate over. The kwarg names will be used as column names in the output. Cannot be specified together withelements.
uda make_list()
Signature
udf concat()
Signature
null if either operand is null. Raises if either operand is a non-null, non-array value.
Examples:
udf contains()
Signature
True if value is an element of a JSON array or a key of a JSON object; False otherwise.
Examples:
udf count()
Signature
value occurs in a JSON array.
Examples:
udf dumps()
Signature
json.dumps().
Parameters:
obj(pxt.Json): A JSON-serializable object (dict, list, or scalar).
pxt.String: A JSON-formatted string.
udf flatten()
Signature
udf get()
Signature
key if the value is a JSON object containing it, otherwise default.
Examples:
udf is_empty()
Signature
True if the value is null, an empty array, an empty object, or an empty string; False otherwise
(including for numbers and booleans).
Examples:
udf items()
Signature
[key, value] pairs of a JSON object as a list. keys(), values(), and items() share the
same ordering.
Examples:
udf keys()
Signature
keys(), values(), and items() share the same ordering.
Examples:
udf len()
Signature
null value (or missing path) yields null.
Examples:
udf max()
Signature
null if the array is empty.
Examples:
udf mean()
Signature
null if the array is empty.
Examples:
udf merge()
Signature
other wins.
Returns null if either operand is null. Raises if either operand is a non-null, non-object value.
Examples:
udf min()
Signature
null if the array is empty.
Examples:
udf sum()
Signature
udf values()
Signature
keys(), values(), and items() share the same ordering.
Examples: