Bird
Raised Fist0
dbtdata~20 mins

Cross-team model sharing in dbt - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Cross-team Model Sharing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Cross-team Model Dependencies in dbt

In dbt, when multiple teams share models, how can one team ensure their models correctly depend on models from another team?

ABy referencing the other team's models using the full project and schema name in the ref function, like ref('project_name', 'model_name')
BBy copying the other team's models into their own project to avoid dependencies
CBy using the ref function with only the model name, assuming dbt will find it automatically across projects
DBy manually writing SQL joins without using ref to avoid cross-project references
Attempts:
2 left
💡 Hint

Think about how dbt resolves model references across different projects.

❓ data_output
intermediate
2:00remaining
Output of Cross-project Model Reference in dbt

Given two dbt projects: team_a and team_b. Team B's model sales_summary references Team A's model raw_sales using ref('team_a', 'raw_sales'). What will be the compiled SQL schema and table name for raw_sales in Team B's compiled SQL?

AThe compiled SQL will reference <code>public.raw_sales</code> by default.
BThe compiled SQL will reference <code>team_b.raw_sales</code> ignoring the project name in ref.
CThe compiled SQL will fail to compile due to cross-project reference errors.
DThe compiled SQL will reference <code>team_a.raw_sales</code> with the schema and table name as defined in Team A's project configuration.
Attempts:
2 left
💡 Hint

Consider how dbt compiles references across projects.

🔧 Debug
advanced
2:00remaining
Debugging Cross-team Model Reference Failure

Team B tries to run a model referencing Team A's model using ref('team_a', 'customer_data') but gets an error: Compilation Error: model 'team_a.customer_data' not found. What is the most likely cause?

ATeam B's dbt version is incompatible with Team A's dbt version.
BThe model name <code>customer_data</code> is misspelled in Team B's ref call.
CTeam A's project is not included as a dependency in Team B's <code>packages.yml</code> file.
DTeam B's model is missing a <code>schema.yml</code> file.
Attempts:
2 left
💡 Hint

Think about how dbt knows about other projects' models.

❓ visualization
advanced
2:00remaining
Visualizing Cross-team Model Dependencies

You have two dbt projects: finance and marketing. Finance models depend on marketing models. Which visualization best represents the dependency graph showing cross-team model sharing?

AA pie chart showing the percentage of models per team.
BA directed graph where nodes represent models, edges show dependencies, and edges crossing project boundaries are highlighted in a different color.
CA bar chart showing the number of models per project without dependencies.
DA scatter plot of model run times versus model sizes.
Attempts:
2 left
💡 Hint

Think about how to show relationships and dependencies clearly.

🚀 Application
expert
3:00remaining
Implementing Cross-team Model Sharing with Version Control

Your organization wants to share dbt models across teams with strict version control. Which approach best supports this goal?

APublish shared models as a versioned dbt package in a private repository, and have consuming teams specify exact package versions in their <code>packages.yml</code>.
BDisable dbt's dependency management and manually manage SQL files across teams.
CUse a shared database schema for all teams without versioning, relying on communication to manage changes.
DCopy shared models into each team's project and update manually when changes occur.
Attempts:
2 left
💡 Hint

Consider how to manage versions and dependencies cleanly in dbt.

Practice

(1/5)
1. What is the main benefit of using ref() in dbt for cross-team model sharing?
easy
A. It allows teams to write raw SQL without any dependencies.
B. It automatically creates new tables in the database without configuration.
C. It connects models from different teams to avoid duplication and ensure consistency.
D. It disables model version control to speed up development.

Solution

  1. Step 1: Understand the purpose of ref() in dbt

    ref() is used to reference other models, enabling dependency tracking and collaboration.
  2. Step 2: Identify the benefit in cross-team sharing

    By using ref(), teams avoid duplicating models and keep data consistent across projects.
  3. Final Answer:

    It connects models from different teams to avoid duplication and ensure consistency. -> Option C
  4. Quick Check:

    Cross-team sharing = ref() connects models [OK]
Hint: Remember: ref() links models to share work [OK]
Common Mistakes:
  • Thinking ref() creates tables automatically
  • Believing ref() removes dependencies
  • Confusing ref() with raw SQL execution
2. Which of the following is the correct syntax to reference a model named sales_summary in dbt?
easy
A. select * from ref('sales_summary')
B. select * from {{ ref('sales_summary') }}
C. select * from sales_summary
D. select * from {{ sales_summary }}

Solution

  1. Step 1: Recall dbt syntax for referencing models

    dbt uses Jinja templating with double curly braces and ref() to reference models.
  2. Step 2: Identify correct syntax

    The correct syntax is select * from {{ ref('model_name') }} to properly resolve the model.
  3. Final Answer:

    select * from {{ ref('sales_summary') }} -> Option B
  4. Quick Check:

    Use {{ ref('model') }} for model references [OK]
Hint: Use double curly braces with ref() for model references [OK]
Common Mistakes:
  • Omitting curly braces around ref()
  • Using ref() without quotes
  • Trying to reference model without ref()
3. Given two teams with models team_a.orders and team_b.customers, what will be the result of this dbt model SQL?
select o.order_id, c.customer_name
from {{ ref('orders') }} o
join {{ ref('customers') }} c on o.customer_id = c.customer_id
medium
A. A joined table of orders and customers combining data from both teams.
B. An error because ref() cannot reference models from other teams.
C. A table with only orders data, ignoring customers.
D. A table with only customers data, ignoring orders.

Solution

  1. Step 1: Understand ref() cross-team referencing

    ref() allows referencing models across teams if they are in the same dbt project or properly configured.
  2. Step 2: Analyze the SQL query

    The query joins orders and customers on customer_id, combining data from both models.
  3. Final Answer:

    A joined table of orders and customers combining data from both teams. -> Option A
  4. Quick Check:

    ref() joins models across teams = combined data [OK]
Hint: ref() joins models across teams if configured [OK]
Common Mistakes:
  • Assuming ref() cannot cross teams
  • Expecting only one model's data returned
  • Ignoring join condition effect
4. You wrote this dbt model to share data across teams:
select * from {{ ref('team_a.orders') }}

But it fails with an error. What is the likely cause?
medium
A. You cannot use dot notation inside ref(); only model names are allowed.
B. The model team_a.orders does not exist in the project.
C. You forgot to wrap ref() in double curly braces.
D. You need to use source() instead of ref() for cross-team models.

Solution

  1. Step 1: Check ref() usage rules

    ref() accepts only model names without schema or dot notation.
  2. Step 2: Identify error cause

    Using team_a.orders inside ref() causes syntax error; correct usage is just orders.
  3. Final Answer:

    You cannot use dot notation inside ref(); only model names are allowed. -> Option A
  4. Quick Check:

    ref() = model name only, no dots [OK]
Hint: Use only model names inside ref(), no dots [OK]
Common Mistakes:
  • Using schema or team prefix inside ref()
  • Confusing ref() with source()
  • Missing curly braces around ref()
5. Your company has two teams: marketing and sales. Marketing built a model campaign_performance. Sales wants to use it in their model sales_analysis. How should sales correctly reference marketing's model in dbt to ensure cross-team sharing?
hard
A. Duplicate the campaign_performance SQL in sales_analysis to avoid dependencies.
B. Use select * from marketing.campaign_performance without ref().
C. Use select * from {{ source('marketing', 'campaign_performance') }}.
D. Use select * from {{ ref('campaign_performance') }} assuming both models are in the same dbt project.

Solution

  1. Step 1: Understand dbt project structure for cross-team models

    If both teams' models are in the same dbt project, ref() can reference models across folders or teams by model name.
  2. Step 2: Choose correct referencing method

    Using ref('campaign_performance') is the correct way to share models and track dependencies.
  3. Final Answer:

    Use select * from {{ ref('campaign_performance') }} assuming both models are in the same dbt project. -> Option D
  4. Quick Check:

    Cross-team sharing = ref() within same project [OK]
Hint: Use ref() with model name for cross-team sharing in same project [OK]
Common Mistakes:
  • Using raw schema.table without ref()
  • Duplicating SQL instead of referencing
  • Using source() incorrectly for models
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard