What is dbt

dbt (Data Build Tool) - dbt turns modular SQL into tested, documented data models inside our data warehouse. It brings software-engineering best practices (version control, tests, documentation, lineage) to analytics workflows and enables incremental builds that speed refreshes and improve reliability.

Why dbt

Key concepts

Architecture Design

├── /opt/airflow/repo/dags/dashboard/
│   └── dag_dbt_dashboard_daily.py → *main dag to run all dbt models*
│
├── /opt/airflow/repo/dags/dbt_project/ → *dbt related files*
│   └── models/
│				├── intermediate/*
│				├── marts/*
│				└── staging/*
│   ├── profiles.yml
│   └── dbt_project.yml

Example dbt file

models/staging/marts/dm_marketing_trial_expiration.sql

{{
config(
    materialized='table',
    schema='marts'
)
}}
SELECT
    company_id,
    company_name,
    contact_phone,
    contact_email,
    trial_start_date,
    expiration_date,
    days_until_expiration AS days_left,
    expiration_segment,
    refresh_date
FROM {{ref('int_marketing_trial_expiration')}}
WHERE days_until_expiration BETWEEN 0 and 5
ORDER BY days_left, company_name

How dbt sped up our dashboard