You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SPARK-38404][SQL] Improve CTE resolution when a nested CTE references an outer CTE
### What changes were proposed in this pull request?
Please note that the bug in the [SPARK-38404](https://issues.apache.org/jira/browse/SPARK-38404) is fixed already with #34929.
This PR is a minor improvement to the current implementation by collecting already resolved outer CTEs to avoid re-substituting already collected CTE definitions.
### Why are the changes needed?
Small improvement + additional tests.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Added new test case.
Closes#36146 from peter-toth/SPARK-38404-nested-cte-references-outer-cte.
Authored-by: Peter Toth <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Copy file name to clipboardExpand all lines: sql/core/src/test/resources/sql-tests/results/cte-nested.sql.out
+17-1Lines changed: 17 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
-- Automatically generated by SQLQueryTestSuite
2
-
-- Number of queries: 16
2
+
-- Number of queries: 17
3
3
4
4
5
5
-- !query
@@ -227,3 +227,19 @@ struct<>
227
227
-- !query output
228
228
org.apache.spark.sql.AnalysisException
229
229
Name aBc is ambiguous in nested CTE. Please set spark.sql.legacy.ctePrecedencePolicy to CORRECTED so that name defined in inner CTE takes precedence. If set it to LEGACY, outer CTE definitions will take precedence. See more details in SPARK-28228.
0 commit comments