[ 
https://issues.apache.org/jira/browse/SPARK-58419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ganesha S updated SPARK-58419:
------------------------------
    Description: 
h3. What

Add support for the ANSI SQL {{UNNEST}} collection derived table in the FROM
clause:
{code:sql}
UNNEST ( expression [ , ... ] ) [ WITH ORDINALITY ] [ table_alias ]
{code}
{{UNNEST}} expands one or more arrays into a relation, producing one row per
element. When several arrays are supplied they are expanded in parallel: the
number of output rows equals the length of the longest array, and shorter
arrays are padded with NULLs. A NULL array is treated as an empty array and
contributes no rows. {{WITH ORDINALITY}} appends a trailing 1-based BIGINT
position column. Correlated arrays (e.g. {{{}FROM t, LATERAL UNNEST(t.arr){}}}) 
are
supported through the existing LATERAL machinery, and {{LEFT JOIN LATERAL
UNNEST(...) ON true}} preserves outer rows whose array is empty or NULL.
h3. Why

{{UNNEST}} is part of the SQL:2016 standard and is available in PostgreSQL,
Trino/Presto, and BigQuery (and, via FLATTEN, Snowflake). Spark currently has
no equivalent ANSI syntax: users must rewrite {{UNNEST(...)}} to {{LATERAL VIEW
EXPLODE}} or the DataFrame {{explode}} API. This is a recurring, whole-user-base
migration pain point when porting queries from other engines. This change closes
a genuine standards-compliance gap; array expansion is an everyday operation, so
the reach is broad.

  was:
h3. 
What

Add support for the ANSI SQL \{{UNNEST}} collection derived table in the FROM
clause:

{code:sql}
UNNEST ( expression [ , ... ] ) [ WITH ORDINALITY ] [ table_alias ]
{code}

{\{UNNEST}} expands one or more arrays into a relation, producing one row per
element. When several arrays are supplied they are expanded in parallel: the
number of output rows equals the length of the longest array, and shorter
arrays are padded with NULLs. A NULL array is treated as an empty array and
contributes no rows. \{{WITH ORDINALITY}} appends a trailing 1-based BIGINT
position column. Correlated arrays (e.g. \{{FROM t, LATERAL UNNEST(t.arr)}}) are
supported through the existing LATERAL machinery, and {{LEFT JOIN LATERAL
UNNEST(...) ON true}} preserves outer rows whose array is empty or NULL.
h3. Why

{\{UNNEST}} is part of the SQL:2016 standard and is available in PostgreSQL,
Trino/Presto, and BigQuery (and, via FLATTEN, Snowflake). Spark currently has
no equivalent ANSI syntax: users must rewrite \{{UNNEST(...)}} to {{LATERAL VIEW
EXPLODE}} or the DataFrame \{{explode}} API. This is a recurring, 
whole-user-base
migration pain point when porting queries from other engines. This change closes
a genuine standards-compliance gap; array expansion is an everyday operation, so
the reach is broad.


> [SQL] Support ANSI SQL UNNEST in the FROM clause
> ------------------------------------------------
>
>                 Key: SPARK-58419
>                 URL: https://issues.apache.org/jira/browse/SPARK-58419
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 4.2.0
>            Reporter: Ganesha S
>            Priority: Major
>
> h3. What
> Add support for the ANSI SQL {{UNNEST}} collection derived table in the FROM
> clause:
> {code:sql}
> UNNEST ( expression [ , ... ] ) [ WITH ORDINALITY ] [ table_alias ]
> {code}
> {{UNNEST}} expands one or more arrays into a relation, producing one row per
> element. When several arrays are supplied they are expanded in parallel: the
> number of output rows equals the length of the longest array, and shorter
> arrays are padded with NULLs. A NULL array is treated as an empty array and
> contributes no rows. {{WITH ORDINALITY}} appends a trailing 1-based BIGINT
> position column. Correlated arrays (e.g. {{{}FROM t, LATERAL 
> UNNEST(t.arr){}}}) are
> supported through the existing LATERAL machinery, and {{LEFT JOIN LATERAL
> UNNEST(...) ON true}} preserves outer rows whose array is empty or NULL.
> h3. Why
> {{UNNEST}} is part of the SQL:2016 standard and is available in PostgreSQL,
> Trino/Presto, and BigQuery (and, via FLATTEN, Snowflake). Spark currently has
> no equivalent ANSI syntax: users must rewrite {{UNNEST(...)}} to {{LATERAL 
> VIEW
> EXPLODE}} or the DataFrame {{explode}} API. This is a recurring, 
> whole-user-base
> migration pain point when porting queries from other engines. This change 
> closes
> a genuine standards-compliance gap; array expansion is an everyday operation, 
> so
> the reach is broad.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to