pyflink.table.expressions.json_object_agg#
- json_object_agg(on_null: pyflink.table.expression.JsonOnNull, key_expr: Union[str, pyflink.table.expression.Expression[str]], value_expr) pyflink.table.expression.Expression [source]#
Builds a JSON object string by aggregating key-value expressions into a single JSON object.
The key expression must return a non-nullable character string. Value expressions can be arbitrary, including other JSON functions. If a value is NULL, the on_null behavior defines what to do.
Note that keys must be unique. If a key occurs multiple times, an error will be thrown.
This function is currently not supported in OVER windows.
Examples:
>>> # '{"Apple":2,"Banana":17,"Orange":0}' >>> orders.select(json_object_agg(JsonOnNull.NULL, col("product"), col("cnt")))
New in version 1.12.0.