Install
packages.yml:
packages:
- package: dbt-labs/dbt_utils
version: 1.3.0
- package: calogica/dbt_expectations
version: 0.10.4
- package: dbt-labs/codegen
version: 0.13.1
Run dbt deps. Packages land in dbt_packages/ (gitignored).
dbt_utils — mandatory
The first package everyone installs.
Surrogate keys
{{ dbt_utils.generate_surrogate_key(['customer_id', 'effective_from']) }}
Star
SELECT {{ dbt_utils.star(from=ref('stg_orders'), except=['_fivetran_synced']) }}
FROM {{ ref('stg_orders') }}
Pivot
SELECT user_id, {{ dbt_utils.pivot('order_status', ['pending', 'paid', 'cancelled']) }}
FROM {{ ref('fct_orders') }} GROUP BY 1
Recency test
tests:
- dbt_utils.recency:
datepart: day
field: order_placed_at
interval: 1
Expression is true
- dbt_utils.expression_is_true:
expression: "row_count_today > 0.5 * row_count_yesterday"
Date spine
{{ dbt_utils.date_spine(
datepart="day",
start_date="cast('2024-01-01' as date)",
end_date="cast(current_date as date)"
) }}
dbt_expectations
Expressive tests inspired by Great Expectations:
columns:
- name: revenue
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 1000000
codegen
Generates boilerplate:
dbt run-operation generate_source --args 'schema_name: raw_shopify'
dbt run-operation generate_base_model --args '{source_name: shopify, table_name: orders}'
Saves weeks of typing.
dbt_artifacts
Captures dbt run history to your warehouse. Useful for slow-model monitoring and SLA dashboards.
elementary
Open-source data observability. Anomaly detection on top of dbt tests.
Source-system packages
fivetran/shopify, fivetran/stripe, etc. — pre-built staging models. If your source is on Fivetran, there's probably a package.
Versioning
- package: dbt-labs/dbt_utils
version: 1.3.0 # exact pin in prod
Common mistakes
- Not using packages — reinventing dbt_utils.
- Pinning too loosely in prod.
- Modifying installed package code — never edit
dbt_packages/.
Takeaway
dbt_utils mandatory. dbt_expectations for richer tests. codegen for boilerplate. Pin exact in production.