Ask AI

You are viewing an unreleased or outdated version of the documentation

Dagster & dbt quickstart#

This quickstart will get your dbt project up and running quickly with Dagster. By the end of this guide, you'll have an integrated Dagster and dbt project and be able to view it in the Dagster UI.

Prerequisites

To complete the steps in this guide, you'll need:

  • A valid dbt project
    • A dbt project must contain the dbt_project.yml and profiles.yml files
    • A test project like Jaffle Shop can be used

Step 1: Set up your environment#

Note: We strongly recommend installing Dagster inside a Python virtualenv. Refer to the Dagster installation docs for more information.

Install dbt, Dagster, and the Dagster webserver by running the following:

pip install dagster-dbt dagster-webserver

The dagster-dbt library installs both dbt-core and dagster as dependencies. Refer to the dbt and Dagster installation docs for more information.

Other requirements based on the dbt project could be needed. In most cases, installing the library that supports your dbt adapter will be required. For instance, dbt-duckdb if you are using DuckDB as a dbt adapter.


Step 2: Load your dbt project into Dagster#

Next, you'll load your dbt project into Dagster. Use the tabs to view instructions for how to accomplish this.

Select one of the following to load your dbt project into Dagster:

  • Option 1: Create a Dagster project in a single file
  • Option 2: Create a new Dagster project that wraps a dbt project by using the dagster-dbt command line interface (CLI)
  • Option 3: Use an existing Dagster project

Step 3: Run your dbt project in the Dagster UI#

Now that your code is ready, you can use the Dagster UI to take a look at your dbt project. Use the tabs to view instructions for starting the UI.

How you start the UI depends on which approach you took to load your dbt project into Dagster:

  • If you created a single Dagster file, use Option 1
  • If you created a new Dagster project or used an existing project, use Option 2

In your browser, navigate to http://127.0.0.1:3000. The page will display the asset graph for the job created by the schedule definition:

Asset graph for your job in Dagster's UI, containing dbt models loaded as Dagster assets

In Dagster, running a dbt model corresponds to materializing an asset. The schedule definition included in your Dagster project's code location (Definitions object) will materialize the assets at its next cron tick.

Assets can also be materialized manually by clicking the Materialize all button near the top right corner of the page.


What's next?#

Congratulations on successfully running your dbt project in Dagster!

To learn more about Dagster's dbt integration and how to handle more complex use cases, you can: