Cyclical Dependencies in dbt (Databricks)

Hello there. Im facing a problem with Cyclical Dependencies in dbt using database: Databricks. Generally, Im trying to replicate some SQL procedures.

I found article, where the guy is solving problem but it is designed for Snowflake not for Databricks.

My workflow and dependecies:


Im using int_model_1 in stg_model_2 which causes an error: RuntimeError: Found a cycle. Basically, in stg_model_2 I need data from int_model_1 from last/previous run.

Any suggestions, how to solve this problem, please?

Im pretty new to dbt, so if you need any additional info, please let me know.

Thank you

Jozef

Hi Jozef,
I have a similar situation and keen to know if you figured the solution for the cyclical dependency in dbt.

Best regards,
Jim

Hey Jozef.

Cyclical dependencies are an antipattern and, even though there are hacks and tricks like your article outlines (or even re-importing a model as source, which I’ve seen done) will probably give you headaches down the line.

I’d suggest you to provide a more in-depth explanation of what stg_model_2 needs to read from int_model_1 so that we can suggest a cleaner approach to the challenge.