Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

trino - Does Presto SQL support recursive query using CTE just like SQL Server? e.g. employee hierarchy level

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 See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...