0
0
dbtdata~30 mins

Creating your own dbt package - Try It Yourself

Choose your learning style9 modes available
Creating your own dbt package
📖 Scenario: You work as a data analyst in a company that uses dbt (data build tool) to manage data transformations. You want to create your own reusable dbt package to organize your SQL models and share them with your team.
🎯 Goal: Build a simple dbt package with a model that selects data from a source table, configure the package, and run it to see the output.
📋 What You'll Learn
Create a dbt package folder structure
Write a simple SQL model file
Add a dbt_project.yml configuration file
Run the dbt model and display the results
💡 Why This Matters
🌍 Real World
Data teams use dbt packages to organize and share data transformation logic efficiently.
💼 Career
Knowing how to create and manage dbt packages is valuable for data analysts and engineers working with modern data stacks.
Progress0 / 4 steps
1
Set up the dbt package folder and model
Create a folder named my_dbt_package. Inside it, create a folder named models. Inside models, create a file named my_first_model.sql with the exact content: select 1 as id, 'dbt package' as description.
dbt
Need a hint?

Remember to create folders my_dbt_package and models inside it. Then create the SQL file with the exact select statement.

2
Add the dbt_project.yml configuration file
Inside the my_dbt_package folder, create a file named dbt_project.yml. Add the exact content:
name: 'my_dbt_package' version: '1.0' config-version: 2 profile: 'default' model-paths: ['models'] target-path: 'target'
dbt
Need a hint?

Make sure the dbt_project.yml file is inside my_dbt_package folder and has the exact keys and values.

3
Run the dbt model
Run the dbt command to build the model inside the my_dbt_package folder. Use the command dbt run --project-dir my_dbt_package to execute the model.
dbt
Need a hint?

Use the exact command dbt run --project-dir my_dbt_package to run your model.

4
Display the model output
After running the model, query the built table named my_first_model in your data warehouse or use dbt run-operation to check the output. For this exercise, print the expected output: id | description 1 | dbt package.
dbt
Need a hint?

Print the exact output lines as shown to simulate the model result.