英文:
needs assistance in writing cte recursive in py spark azure databricks which is in below sql format
问题
WITH RECURSIVE dates(dt) AS
(
SELECT to_date('2023-03-05') - 181 as dt
UNION ALL
SELECT dt + 1
FROM dates d
WHERE d.dt < to_date('2023-03-05')
)
我已经尝试了下面的SQL代码在SQL框架中,但在Databricks中无法工作。
WITH RECURSIVE dates(dt) AS
(
SELECT to_date('2023-03-05') - 181 as dt
UNION ALL
SELECT dt + 1
FROM dates d
WHERE d.dt < to_date('2023-03-05')
)
英文:
WITH RECURSIVE dates(dt) AS
(
SELECT to_date('2023-03-05') -181 as dt
UNION ALL
SELECT dt + 1
FROM dates d
WHERE d.dt < to_date('2023-03-05')
)
I have tried with below code under sql frame work its not working in databricks
WITH RECURSIVE dates(dt) AS
(
SELECT to_date('2023-03-05') -181 as dt
UNION ALL
SELECT dt + 1
FROM dates d
WHERE d.dt < to_date('2023-03-05')
)
答案1
得分: 0
Apache Spark不支持原生递归CTE语法。您可以使用Jira SPARK-24497来跟踪状态。
在它被实现之前,您需要使用一些解决方法,如在以下文章中描述的 - 您可以结合使用常规CTE和联合。
英文:
Apache Spark doesn't support native recursive CTE syntax. You can track the status using the SPARK-24497 Jira.
Until it's implemented you will need to use some workarounds, like, described in the following article - where you can do a combination of normal CTE and unions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论