0
0
dbtdata~20 mins

Creating your own dbt package - Practice Exercises

Choose your learning style9 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.