0
0
dbtdata~10 mins

Cross-team model sharing in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Cross-team model sharing
Create model in Team A
Test and document model
Publish model to shared dbt package
Team B adds dependency on shared package
Team B references Team A's model
Run dbt to build combined models
Teams collaborate on improvements
Teams create and test models, publish them as shared packages, then other teams add dependencies and reference these models to build combined data workflows.
Execution Sample
dbt
models/team_a/my_model.sql
-- select statement

models/team_b/analysis.sql
-- select from {{ ref('my_model') }}
Team A creates a model, Team B references it in their own model using dbt's ref function.
Execution Table
StepActionEvaluationResult
1Team A writes my_model.sqlSQL compilesModel my_model created
2Team A runs dbt buildModel builds successfullyTable/view my_model created in warehouse
3Team A packages model in shared dbt packagePackage readyPublished for sharing
4Team B adds dependency on Team A's packageDependency resolvedTeam B can reference my_model
5Team B writes analysis.sql referencing my_modelReference compilesModel analysis ready
6Team B runs dbt buildBuild runsanalysis model created using my_model data
7Teams collaborate on updatesModels updatedImproved shared models
8ExitNo more changesProcess complete
💡 Teams finish sharing and building models; collaboration cycle ends
Variable Tracker
VariableStartAfter Step 2After Step 4After Step 6Final
my_modelNot createdCreated in warehouseAvailable in packageUsed by analysis modelShared and updated
analysis_modelNot createdNot createdNot createdCreated in warehouseBuilt and updated
Key Moments - 3 Insights
How does Team B access Team A's model?
Team B adds Team A's dbt package as a dependency and uses the ref function to reference Team A's model, as shown in execution_table step 4 and 5.
Why is testing and documenting important before sharing?
Testing ensures the model works correctly and documentation helps other teams understand how to use it, preventing errors during referencing (see step 2).
What happens if Team A updates their model?
Teams rerun dbt build to update dependent models, enabling collaboration and continuous improvement (step 7).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does Team B first use Team A's model?
AStep 3
BStep 4
CStep 5
DStep 6
💡 Hint
Check the 'Action' column where Team B writes analysis.sql referencing my_model (step 5).
According to variable_tracker, what is the state of 'my_model' after Step 4?
AAvailable in package
BCreated in warehouse
CNot created
DUsed by analysis model
💡 Hint
Look at the 'my_model' row under 'After Step 4' column in variable_tracker.
If Team A skips testing before sharing, what step in execution_table might fail?
AStep 4
BStep 2
CStep 5
DStep 7
💡 Hint
Testing happens before or during Step 2 when Team A runs dbt build.
Concept Snapshot
Cross-team model sharing in dbt:
- Team A creates and tests models
- Models are packaged and published
- Team B adds dependency on shared package
- Team B references Team A's models with ref()
- Run dbt build to compile and run combined models
- Teams collaborate to improve shared models
Full Transcript
Cross-team model sharing in dbt involves one team creating and testing data models, then packaging and publishing them as shared dbt packages. Other teams add these packages as dependencies and reference the shared models using dbt's ref function. Running dbt build compiles and runs all models, creating combined data outputs. This process enables teams to collaborate by sharing tested, documented models and improving them together over time.