Ganesha S created SPARK-62414:
---------------------------------
Summary: Support NESTED PATH in JSON_TABLE
Key: SPARK-62414
URL: https://issues.apache.org/jira/browse/SPARK-62414
Project: Spark
Issue Type: Improvement
Components: SQL
Affects Versions: 4.3.0
Reporter: Ganesha S
JSON_TABLE currently supports only flat COLUMNS. To expand nested arrays you
have to chain one LATERAL JSON_TABLE per level, and each level parses its part
of the document again from text. The cost grows with depth: about 3.5x slower
than explode at 1 level and 7.5x at 6 levels.
The SQL standard's NESTED PATH lets a single JSON_TABLE expand nested arrays:
{code:sql}
SELECT * FROM JSON_TABLE(json, '$.orders[*]'
COLUMNS (
order_id BIGINT PATH '$.id',
NESTED PATH '$.items[*]' COLUMNS (
sku STRING PATH '$.sku',
qty INT PATH '$.qty')))
{code}
Proposal: support NESTED PATH following the SQL standard (as in Oracle and
MySQL):
* a parent row is kept, with NULLs, when its nested path matches nothing
* sibling nested paths do not multiply rows with each other
This should build on the single-pass reader from the JSON_TABLE parsing
sub-task, so all levels are read in one pass.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]