Skip to content

Redshift error when using recursive CTE

0

I'm trying to run this query on redshift, but I have an **ERROR: Assert **

with recursive tbl(col1, col2) as (
    select 1 as col1, 'str_' as col2
    union all
    select (col1 + 1) as col1, 'str' as col2
    from tbl
    where col1 < 5
)
select * from tbl;
asked a year ago313 views
1 Answer
0
Accepted Answer

I tried something similar and it seems to work. So what is it they you are trying to get to here?

with recursive tbl(col1, col2) as (
    select 1 as col1, 10 as col2
    union all
    select col1+1 as col1, col2
    from tbl 
    where col1 < 5
)
select * from tbl;
AWS
EXPERT
answered a year ago
AWS
EXPERT
reviewed 4 months ago
  • Nicely done thanks ! So I had this error in my query (thanks for the solution !), but another problem (the major one) comes from dbt. It doesn't seem to support Recursive CTE : Runtime Error Database Error in sql_operation inline_query (from remote system.sql) Recursive CTE in subquery are not supported. I submitted a ticket with that to dbt labs.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.