Jarno Rajala created SPARK-39198: ------------------------------------ Summary: Cannot refer to nested CTE within a nested CTE in a subquery. Key: SPARK-39198 URL: https://issues.apache.org/jira/browse/SPARK-39198 Project: Spark Issue Type: Bug Components: SQL Affects Versions: 3.2.1 Environment: Tested on * Databricks runtime 10.4 * Spark 3.2.1 from [https://spark.apache.org/downloads.html] * GitHub apache/spark 'master' commit 17b85ff9 Reporter: Jarno Rajala
The following query fails with {color:#FF0000}Table or view not found: cte1;{color} {{set spark.sql.legacy.ctePrecedencePolicy=CORRECTED;}} {{with}} {{{}cte1 as (select 1){}}}{{{}select * from ({}}} {{ with}} {{ cte2 as (select * from cte1)}} {{ select * from cte2}} {{);}} Or Spark 3.1.1 it returns 1 as expected. This is related to [SPARK-38404|https://issues.apache.org/jira/browse/SPARK-38404], but different, since the query fails with Spark built from 'master' (commit 17b85ff9). The [PR #36146|https://github.com/apache/spark/pull/36146] therefore does not fix this issue. -- This message was sent by Atlassian Jira (v8.20.7#820007) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org