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

Dongjoon Hyun updated SPARK-28297:
----------------------------------
    Affects Version/s:     (was: 3.0.0)
                       3.1.0

> Handling outer links in CTE subquery expressions
> ------------------------------------------------
>
>                 Key: SPARK-28297
>                 URL: https://issues.apache.org/jira/browse/SPARK-28297
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.1.0
>            Reporter: Peter Toth
>            Priority: Major
>
> This query does work in Spark SQL:
> {noformat}
> select (with cte(x) as (select 1) select x from cte) from test10
> {noformat}
> But the following query can't handle the outer reference to the {{c}} column 
> of {{test10}} table:
> {noformat}
> select (with cte(x) as (select c) select x from cte) from test10
> org.apache.spark.sql.AnalysisException: Expressions referencing the outer 
> query are not supported outside of WHERE/HAVING clauses:
> Project [outer(c#41)]
> +- OneRowRelation
> ;;
> Project [scalar-subquery#167 [] AS scalarsubquery()#169]
> :  +- Project [x#168]
> :     +- SubqueryAlias `cte`
> :        +- Project [c#41 AS x#168]
> :           +- Project [outer(c#41)]
> :              +- OneRowRelation
> +- SubqueryAlias `default`.`test10`
>    +- Relation[c#41] parquet
> {noformat}
> where test10:
> {noformat}
> CREATE TABLE test10 (c INTEGER);
> INSERT INTO test10 SELECT generate_sequence(1, 10);
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to