我想在 Presto 中使用 CTE 编写一个递归查询来查找员工层次结构。Presto 支持递归查询吗?当我将简单的递归写为
with cte as(select 1 n
union all
select cte.n+1 from cte where n<50)
select * from cte
它给出的错误是
运行查询时出错:第 3:32 行:表 cte 不存在当前答案
绝对地!自 Presto 340(现为 Trino)以来。
旧答案
Presto 语法支持WITH RECURSIVE name AS ...,但没有实现递归 WITH 查询。
这作为功能请求进行跟踪:https : //github.com/trinodb/trino/issues/1122