You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Wenchen Fan (Jira)" <ji...@apache.org> on 2026/07/31 13:57:00 UTC
[jira] [Resolved] (SPARK-58419) [SQL] Support ANSI SQL UNNEST in the FROM clause
[ https://issues.apache.org/jira/browse/SPARK-58419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Wenchen Fan resolved SPARK-58419.
---------------------------------
Fix Version/s: 4.3.0
Resolution: Fixed
Issue resolved by pull request 57630
[https://github.com/apache/spark/pull/57630]
> [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
> Assignee: Ganesha S
> Priority: Major
> Labels: pull-request-available
> Fix For: 4.3.0
>
>
> 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 pain point for the whole user base 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: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org