json_tuple table-valued generator function

Returns multiple JSON objects as a tuple.

Syntax

json_tuple(jsonStr, path1 [, ...] )

Arguments

  • jsonStr: A STRING expression with well formed JSON.

  • pathN: A STRING literal with a JSON path.

Returns

A row composed of the other expressions in the select list and the JSON objects.

If any object cannot be found NULL is returned for that object. The column alias for the produced columns are by default named c1, c2, etc., but can be aliased using AS (myC1, myC2, …).

json_tuple can only be placed in the select list or a LATERAL VIEW. When placing the function in the select list there must be no other generator function in the same select list.

Examples

> SELECT json_tuple('{"a":1, "b":2}', 'a', 'b'), 'Spark SQL';
 1  2  Spark SQL
> SELECT json_tuple('{"a":1, "b":2}', 'a', 'c'), 'Spark SQL';
 1  NULL  Spark SQL