dbt + Bruin AI Data Analyst
Verify the dbt project
Reference project layout
The reference project ends up looking like this. The context/ directory is what this guide produces - everything else is dbt prerequisites:
contoso-dbt/
├── ingest/pipeline.py # dlt - loads raw tables to BigQuery
├── models/ # dbt - staging + reports
│ ├── sources.yml
│ ├── staging/stg_*.sql (10)
│ └── reports/rpt_*.sql (7)
├── context/ # ← the Bruin context layer (this guide)
│ ├── .bruin.yml
│ ├── pipeline.yml
│ └── assets/
│ ├── contoso_dbt_raw/*.asset.yml (23)
│ ├── contoso_dbt_staging/*.asset.yml (10)
│ └── contoso_dbt_reports/*.asset.yml (7)
├── AGENTS.md # how agents should use the context
└── run_pipeline.sh # dlt ingest + dbt build
The end state is 40 YAMLs - one per materialized table - covering raw ingest, staging, and reports.
What the dbt half looks like
The contoso-dbt project uses a fairly standard dbt-on-BigQuery setup. If yours looks similar, you're ready:
- A
dbt_project.ymland aprofiles.yml(the reference uses OAuth viagcloud auth application-default login, locationEU) - A
models/sources.ymldeclaring raw tables loaded by dlt into a*_rawschema - Staging models (
stg_*.sql) materialized into a*_stagingschema - Report / mart models (
rpt_*.sql) materialized into a*_reportsschema - A
generate_schema_name.sqlmacro so a+schema: stagingconfig lands ascontoso_dbt_staging, notcontoso_dbt_contoso_dbt_staging dbt buildruns cleanly and the tables exist in the warehouse
Heads up on schema naming. dbt's default
generate_schema_namemacro concatenates the target schema with the+schemaconfig, which is rarely what you want. The reference project overrides it to use the+schemavalue directly. If your final schema names look doubled-up, this is usually why.
Verify the warehouse has data
Before moving to the Bruin steps, make sure your dbt-built tables actually exist. From your dbt project root:
dbt build
Then spot-check the warehouse. For BigQuery:
bq ls bruin-playground-arsalan:contoso_dbt_staging
bq ls bruin-playground-arsalan:contoso_dbt_reports
For Postgres / Redshift:
SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_schema IN ('contoso_dbt_staging', 'contoso_dbt_reports')
ORDER BY 1, 2;
You should see one row per materialized model. If a model is missing, fix dbt before continuing - Bruin will simply skip what isn't there.