-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-51720][SQL] Add Cross Join as legal in recursion of Recursive CTE #50308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-51720][SQL] Add Cross Join as legal in recursion of Recursive CTE #50308
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and this scenario is allowed in some engines (like postgresql), but I would suggest a more intuitive test case like:
WITH RECURSIVE
x(id) AS (SELECT 1 UNION SELECT 2),
t(id, xid) AS (
SELECT 0 AS id, 0 AS xid
UNION ALL
SELECT t.id + 1, xid * 10 + x.id FROM t CROSS JOIN x WHERE t.id < 3
)
SELECT * FROM t
id | xid
-- | --
0 | 0
1 | 1
1 | 2
2 | 11
2 | 12
2 | 21
2 | 22
3 | 111
3 | 112
3 | 121
3 | 122
3 | 211
3 | 212
3 | 221
3 | 222
Added this test too. Thanks! |
@Pajaraja How about new JIRA? Specifically for the changes. |
Added. |
### What changes were proposed in this pull request? Add Cross Joins as legal in recursion in Recursive CTEs. ### Why are the changes needed? Cross join is allowed in the recursion plan of Recursive CTEs in postgreSQL. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Add test to golden file cte-recursion.sql. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#50308 from Pajaraja/pavle-martinovic_data/CrossJoinRecursiveCTE2. Authored-by: pavle-martinovic_data <[email protected]> Signed-off-by: Peter Toth <[email protected]>
What changes were proposed in this pull request?
Add Cross Joins as legal in recursion in Recursive CTEs.
Why are the changes needed?
Cross join is allowed in the recursion plan of Recursive CTEs in postgreSQL.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Add test to golden file cte-recursion.sql.
Was this patch authored or co-authored using generative AI tooling?
No.