Pavle Martinović created SPARK-52311:
----------------------------------------

             Summary: Fix bug with multiple self-references with 
UnresolvedSubqueryA in rCTEs
                 Key: SPARK-52311
                 URL: https://issues.apache.org/jira/browse/SPARK-52311
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 4.1.0
            Reporter: Pavle Martinović


Currently rCTEs don't behave properly in case when the anchor references the 
same column multiple times in the anchor, leading to wrong things being 
identified in the recursion.
For example this rCTE:

 
WITH RECURSIVE tmp(x) AS (
values (1), (2), (3), (4), (5)
), rcte(x, y) AS (
SELECT x, x FROM tmp WHERE x = 1
UNION ALL
SELECT x + 1, x FROM rcte WHERE x < 5
)
SELECT * FROM rcte;
 
Will return:
1 1
2 2
3 3
4 4
5 5
 
Instead of:
1 1
2 1
3 2
4 3
5 4
 
Due to a collision in the names found by the anchor. 



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

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

Reply via email to