Set up the dbt project
In this part of the tutorial, you will:
Step 1: Download the sample dbt project
Let's get started by downloading a sample dbt project. We'll use the standard dbt Jaffle Shop example.
-
First, create a folder that will ultimately contain both your dbt project and Dagster code.
mkdir tutorial-dbt-dagster
-
Then, navigate into that folder:
cd tutorial-dbt-dagster
-
Finally, download the sample dbt project into that folder.
git clone https://github.com/dbt-labs/jaffle_shop.git
Step 2: Configure your dbt project to run with DuckDB
Running dbt requires a data warehouse to store the tables that are created from the dbt models. For our data warehouse, we'll use DuckDB, because setting it up doesn't require any long-running services or external infrastructure.
You'll set up dbt to work with DuckDB by configuring a dbt profile:
-
Navigate into the
jaffle_shop
folder, which was created when you downloaded the project, inside yourtutorial-dbt-dagster
folder:cd jaffle_shop
-
In this folder, with your text editor of choice, create a file named
profiles.yml
and add the following code to it:jaffle_shop:
target: dev
outputs:
dev:
type: duckdb
path: tutorial.duckdb
threads: 24
Step 3: Build your dbt project
With the profile configured above, your dbt project should now be usable. To test it out, run:
dbt build
This will run all the models, seeds, and snapshots in the project and store a set of tables in your DuckDB database.
For other dbt projects, you may need to run additional commands before building the project. For instance, a project with dependencies will require you to run dbt deps
before building the project. For more information, see the official dbt Command reference page.
What's next?
At this point, you should have a fully-configured dbt project that's ready to work with Dagster. The next step is to load the dbt models into Dagster as assets.