내용으로 건너뛰기

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;

질문됨 2년 전578회 조회

1개 답변
0
수락된 답변

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
전문가

답변함 2년 전

전문가

검토됨 일 년 전

  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.