dbt ref() vs source()
Asked Answered
S

1

16

I’m trying to make one model in dbt depend 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?

Schlessel answered 20/9, 2022 at 10:0 Comment(1)
L
25

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

Lenoralenore answered 23/9, 2022 at 18:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.