Open migueldichoso opened 3 months ago
Seconding this! I have a few instances where I need to use recursion, and it's annoying not to be able to build/test my work the same way I do for everything else. I get the same error, even though my queries run normally and do not error in the AWS Console/Redshift Query Editor, and dbt is able to build and test the resulting tables successfully.
Thanks @Caitlin-Syntax! I think we're going to resolve this issue by changing the default behavior of get_show_sql
to avoid wrapping in a subquery, given edge cases like this one:
Any news on this bug ? Our pipelines are blocked by this issue :/
@ashrafkasmipfs you likely have a different issue if your pipelines are blocked. This only affects the Preview functionality in the Cloud IDE; it does not impact Build, Run, or Test functionality in the Cloud IDE (or elsewhere), and it does not affect Job execution. The problem here is that the Preview function wraps up the compiled SQL as a subquery to apply a LIMIT clause (e.g. SELECT * FROM (your query) as model_limit_subq limit 500
), but Build doesn't add the extra wrapper. It could be that you have a macro or something else that's causing your recursive CTE to get wrapped.
Is this a new bug in dbt-redshift?
Current Behavior
When I preview a recursive CTE in dbt cloud IDE, I am getting an error![image](https://github.com/dbt-labs/dbt-redshift/assets/156803309/fbbd2a29-eaad-4a87-9022-ee769d802004)
Recursive CTE in subquery are not supported.
The same recursive CTE query run successfully withdbt run
ordbt build
. It also works fine with other datawarehouse such as Snowflake.Expected Behavior
The Preview button should show successful output when previewed the recursive CTE query.![image](https://github.com/dbt-labs/dbt-redshift/assets/156803309/9930b8f5-9b04-46dc-9c1e-c4c3a0d23fbe)
Steps To Reproduce
select * from daily_dates
Runtime Error Database Error in sql_operation inline_query (from remote system.sql) Recursive CTE in subquery are not supported. Encountered an error: Runtime Error Database Error in sql_operation inline_query (from remote system.sql) Recursive CTE in subquery are not supported.
dbt run
.Additional Context
No response