Referencing Another Model
Create a model that’s based on another model.
We'll cover the following
Selecting from a model
In dbt, referencing another model is a powerful feature that enables us to build new models on top of existing ones. By doing so, we can reuse the logic and calculations from the base model without duplicating code. This not only enhances code maintainability but also ensures that changes in the base model automatically propagate to the dependent models.
The ref()
function in dbt is used to reference an existing model. This function takes the name of the model as an argument and returns the table identifier. Here’s the syntax:
Get hands-on with 1400+ tech skills courses.