How to Use dbt utils

Last updated July 25, 2026 · By the SaturnSQL team

dbt-utils is the standard macro package: add it to packages.yml and run dbt deps to install. Popular macros include generate_surrogate_key for hashed keys, date_spine for calendar tables, and extra generic tests like expression_is_true.

# packages.yml
packages:
  - package: dbt-labs/dbt_utils
    version: [">=1.0.0", "<2.0.0"]
dbt deps

Surrogate key and date spine

SELECT
  {{ dbt_utils.generate_surrogate_key(['customer_id', 'order_date']) }} AS order_key
FROM {{ ref('stg_orders') }}

-- calendar table
{{ dbt_utils.date_spine(
    datepart='day',
    start_date="cast('2024-01-01' as date)",
    end_date="cast('2027-01-01' as date)"
) }}

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related dbt guides

© 2026 Panda Capital Oy Ab. All rights reserved.