First, you'll download Dagster's tutorial_dbt_dagster example and configure the dbt project it contains. This example uses dbt's jaffle shop project, but you can follow along with a different project as well.
Next, you'll tell the dbt models where their source data will be located. There isn't any data yet - we'll create Dagster assets that fetch and provide data to the dbt models later in the tutorial.
In dbt, sources are declared using sources.yml files. We've provided this file for you in /tutorial_template/jaffle_shop/models, which defines the location of tables containing source data:
The Dagster assets you build in part three of this tutorial will create orders_raw and customers_raw tables when materialized. To have the models select data from these tables, you'll need to update the models.
In /tutorial_template/jaffle_shop/models/staging, update the stg_customers.sql and stg_orders.sql models to use the {{ source()}} function. This function tells the dbt model to select data from the defined source. In this example, that's the customers_raw and orders_raw tables in the DuckDB database:.
In stg_customers.sql, replace its contents with the following:
select
id as customer_id,
first_name,
last_name
from {{ source('jaffle_shop','customers_raw') }}
In stg_orders.sql, replace its contents with the following:
select
id as order_id,
user_id as customer_id,
order_date,statusfrom {{ source('jaffle_shop','orders_raw') }}