3
votes

I want to write a recursive query using CTE in Presto to find Employee Hierarchy. Do Presto support recursive query? When I write simple recursion as

with cte as(select 1 n union all select cte.n+1 from cte where n<50) select * from cte

It gives error that

Error running query: line 3:32: Table cte does not exist
1

1 Answers

6
votes

Current answer

Recursive queries are supported in Trino, but not PrestoDB implementations of Presto.

Old answer

Presto grammar supports WITH RECURSIVE name AS ..., but recursive WITH queries are not implemented.

This is tracked as a feature request: https://github.com/trinodb/trino/issues/1122