0
0
dbtdata~30 mins

Cross-team model sharing in dbt - Mini Project: Build & Apply

Choose your learning style9 modes available
Cross-team model sharing
📖 Scenario: Your company has multiple teams working on different parts of the data pipeline. Each team builds dbt models for their area. Now, you want to share a model from one team with another team so they can use it in their analysis.
🎯 Goal: Learn how to share a dbt model across teams by creating a model in one project and referencing it in another project.
📋 What You'll Learn
Create a dbt model in the source project
Configure the source project to expose the model
Reference the shared model in the target project
Run dbt to build and verify the shared model
💡 Why This Matters
🌍 Real World
In many companies, different teams build parts of the data pipeline. Sharing dbt models allows teams to reuse work and maintain consistency.
💼 Career
Data engineers and analysts often collaborate using dbt. Knowing how to share models across teams is a valuable skill for maintaining scalable data workflows.
Progress0 / 4 steps
1
Create a dbt model in the source project
In the source dbt project, create a model file called source_team_model.sql inside the models folder. Write a simple SQL query that selects id and name columns from the raw.customers table.
dbt
Need a hint?

Write a simple SELECT statement in source_team_model.sql that selects id and name from raw.customers.

2
Configure the source project to expose the model
In the source dbt project's dbt_project.yml file, add the model source_team_model under the models section and set enabled: true and materialized: view to make it available for sharing.
dbt
Need a hint?

In dbt_project.yml, under models:, add source_team_model: with enabled: true and materialized: view.

3
Reference the shared model in the target project
In the target dbt project, create a model file called target_team_model.sql inside the models folder. Use the ref function to reference the source_team_model from the source project and select all columns from it.
dbt
Need a hint?

In target_team_model.sql, write select * from {{ ref('source_team_model') }} to use the shared model.

4
Run dbt to build and verify the shared model
Run the command dbt run in the target project to build the models. Then run dbt test to verify the models run successfully. Finally, print the message "Shared model built successfully".
dbt
Need a hint?

After running dbt commands, print "Shared model built successfully" to confirm.