Dbt ref() vs source

Viewed 29

I’m trying to make one model in dbt depends on another (trying to run the second model after the first one is completely finished), but I’m confused, when to use ref() or source? What is the difference between them?

Thanks

1 Answers

Using ref creates the lineage for your DAG and will run the predecessor models. Using source references a base table that is not necessarily a model. Rule of thumb is use source in your base models and everything else should use ref.

Example - Green nodes represent tables ingested into your DWH. The blue/red nodes are DBT models. enter image description here

Related