Bird
Raised Fist0
dbtdata~20 mins

Creating your own dbt package - Practice Exercises

Choose your learning style10 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
dbt Package Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
๐Ÿง  Conceptual
intermediate
1:30remaining
What is the primary purpose of a dbt package?

In dbt, why do we create packages?

ATo share reusable models, macros, and analyses across multiple dbt projects
BTo store raw data files for ingestion into the warehouse
CTo schedule dbt runs automatically on a server
DTo create dashboards and visualizations directly within dbt
Attempts:
2 left
๐Ÿ’ก Hint

Think about code reuse and sharing in software projects.

โ“ Predict Output
intermediate
1:30remaining
Output of dbt package.yml dependencies snippet

Given this snippet in packages.yml:

packages:
  - package: fishtown-analytics/dbt_utils
    version: 0.8.0

What does this configuration do when you run dbt deps?

AUploads the current project as a package to the dbt hub
BRuns all models in the dbt_utils package automatically
CDeletes existing packages and resets the project
DDownloads the dbt_utils package version 0.8.0 into the projectโ€™s packages directory
Attempts:
2 left
๐Ÿ’ก Hint

Consider what dbt deps does with the packages.yml file.

โ“ data_output
advanced
2:00remaining
Result of running a custom macro from a dbt package

Assume you have a dbt package with this macro:

{% macro multiply_by_two(value) %}
  {{ value * 2 }}
{% endmacro %}

In your model, you run:

select {{ multiply_by_two(5) }} as result

What will be the output of this model?

AAn empty table with no rows
BA table with one column 'result' and one row with value 10
CA syntax error because macros cannot be used in select statements
DA table with one column 'result' and one row with value 25
Attempts:
2 left
๐Ÿ’ก Hint

Macros return SQL expressions that get rendered into the model SQL.

๐Ÿ”ง Debug
advanced
2:00remaining
Identify the error in this dbt package manifest snippet

Given this packages.yml snippet:

packages:
  - package: dbt-labs/dbt_utils
    version: 0.8.0
  - package: fishtown-analytics/dbt_utils
    version: 0.7.0

What error will dbt raise when running dbt deps?

AError due to conflicting package names for dbt_utils with different versions
BNo error; both packages will be installed side by side
CError because version numbers must be strings, not numbers
DError because the packages.yml file is missing a required 'name' field
Attempts:
2 left
๐Ÿ’ก Hint

Think about package naming conflicts in dependency management.

๐Ÿš€ Application
expert
2:30remaining
How to make your dbt package reusable by others

You created a dbt package locally and want others to use it easily. Which step is essential to make your package publicly reusable?

AInclude your package code directly inside every userโ€™s dbt project
BSend your package files via email to each user
CPublish your package to a public Git repository and register it on the dbt Hub
DRun <code>dbt run</code> on your local machine and share the compiled SQL files
Attempts:
2 left
๐Ÿ’ก Hint

Think about how open source packages are shared and discovered.

Practice

(1/5)
1. What is the main purpose of creating your own dbt package?
easy
A. To reuse and share data models easily across projects
B. To write SQL queries faster
C. To create dashboards automatically
D. To store raw data files

Solution

  1. Step 1: Understand the role of dbt packages

    dbt packages are designed to bundle data models and logic for reuse.
  2. Step 2: Identify the main benefit

    Sharing and reusing models saves time and keeps projects consistent.
  3. Final Answer:

    To reuse and share data models easily across projects -> Option A
  4. Quick Check:

    dbt package purpose = reuse/share models [OK]
Hint: Think: Why share code? To reuse it easily [OK]
Common Mistakes:
  • Confusing packages with dashboards
  • Thinking packages store raw data
  • Believing packages speed up SQL writing only
2. Which file do you edit to add a new dbt package to your main project?
easy
A. models.sql
B. dbt_project.yml
C. profiles.yml
D. packages.yml

Solution

  1. Step 1: Recall where packages are declared

    dbt uses packages.yml to list external or local packages.
  2. Step 2: Differentiate from other config files

    dbt_project.yml configures the project itself, not packages.
  3. Final Answer:

    packages.yml -> Option D
  4. Quick Check:

    Package list file = packages.yml [OK]
Hint: Add packages in packages.yml, not dbt_project.yml [OK]
Common Mistakes:
  • Adding packages in dbt_project.yml
  • Confusing profiles.yml with packages.yml
  • Trying to add packages in SQL files
3. Given this packages.yml snippet:
packages:
  - local: ../my_dbt_package

What command installs this package into your project?
easy
A. dbt install
B. dbt build
C. dbt deps
D. dbt run

Solution

  1. Step 1: Identify the command for package installation

    dbt uses dbt deps to download and install packages listed in packages.yml.
  2. Step 2: Differentiate from other commands

    dbt run runs models, dbt install is not a valid command.
  3. Final Answer:

    dbt deps -> Option C
  4. Quick Check:

    Install packages with dbt deps [OK]
Hint: Use dbt deps to install packages listed in packages.yml [OK]
Common Mistakes:
  • Using dbt install (not a valid command)
  • Confusing dbt run with package install
  • Trying dbt build instead of dbt deps
4. You created a package but when running dbt deps, you get an error: "Could not find package at path '../my_package'". What is the likely cause?
medium
A. The relative path in packages.yml is incorrect or folder missing
B. You forgot to run dbt run first
C. The package name is missing in dbt_project.yml
D. You need to delete the profiles.yml file

Solution

  1. Step 1: Understand the error message

    "Could not find package at path" means dbt cannot locate the folder specified.
  2. Step 2: Check the path in packages.yml

    Relative paths must be correct and folder must exist for local packages.
  3. Final Answer:

    The relative path in packages.yml is incorrect or folder missing -> Option A
  4. Quick Check:

    Path error = wrong folder path [OK]
Hint: Check folder path in packages.yml matches actual location [OK]
Common Mistakes:
  • Running dbt run before dbt deps
  • Editing dbt_project.yml instead of packages.yml
  • Deleting unrelated config files
5. You want to use a model named customer_summary from your custom package my_package. Which is the correct way to reference it in your SQL model?
hard
A. select * from {{ ref('my_package', 'customer_summary') }}
B. select * from {{ ref('my_package.customer_summary') }}
C. select * from {{ ref('customer_summary') }}
D. select * from {{ ref('my_package__customer_summary') }}

Solution

  1. Step 1: Recall how to reference models from packages

    Use ref('package_name.model_name') to refer to models in packages.
  2. Step 2: Check each option's syntax

    select * from {{ ref('my_package.customer_summary') }} uses the correct single-argument ref syntax with dot notation for packages.
  3. Final Answer:

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

    Package model ref = ref('package.model') [OK]
Hint: Use ref('package.model') to access package models [OK]
Common Mistakes:
  • Using ref('package', 'model') syntax (that's for sources)
  • Forgetting the package name in ref
  • Using double underscore instead of dot
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