Skip to content

Fix: Add workaround to ignore source dependency if fqn matches model#5492

Merged
crericha merged 2 commits intomainfrom
ignore-source-if-model
Oct 7, 2025
Merged

Fix: Add workaround to ignore source dependency if fqn matches model#5492
crericha merged 2 commits intomainfrom
ignore-source-if-model

Conversation

@crericha
Copy link
Contributor

@crericha crericha commented Oct 6, 2025

An idiom used in dbt projects is to define a model as both a model and a source to circumvent circular dependencies.

For example:

  • Model A is a cache of load times from an external source
  • Model B is the loaded values form the external source

Model A uses model B to figure out the previous load time by the max timestamp
Model B uses Model A to know what timestamp it needs to fetch from without having to redo that expensive calculation

In this idiom, Model B can be defined also as a source. Model A can then call it using the source() method, circumventing the circular dependency.

However, it does also mean the developer has to make sure the table for Model B is created before Model A is called. Putting the source() call in an is_incremental() block is one way to solve that. There are many more examples.

The purpose of this fix is to not preclude developers from using the idiom, while also making them responsible for resolving the dependency prior to runtime. If the runtime behavior is not resolved, new environments will error when trying to run with a missing table.

If the source/model fqn collision was unintentional, we will no longer catch the circular dependency at load time. It will instead error at runt ime.

@crericha crericha force-pushed the ignore-source-if-model branch from c7e6718 to bccd583 Compare October 6, 2025 21:18
@crericha crericha merged commit 9fc6a2e into main Oct 7, 2025
35 of 36 checks passed
@crericha crericha deleted the ignore-source-if-model branch October 7, 2025 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants