A curated collection of Agent Skills for working with dbt, to help AI agents understand and execute dbt workflows more effectively.
91
91%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Advisory
Suggest reviewing before use
A time spine is essential for time-based joins and aggregations in MetricFlow. It provides the foundation for time-based metrics and dimensions.
Create models/marts/time_spine_daily.sql.
Using dbt.date_spine macro (when supported by your adapter):
{{
config(
materialized = 'table',
)
}}
with
base_dates as (
{{
dbt.date_spine(
'day',
"DATE('2000-01-01')",
"DATE('2030-01-01')"
)
}}
),
final as (
select
cast(date_day as date) as date_day
from base_dates
)
select *
from final
where date_day > dateadd(year, -5, current_date())
and date_day < dateadd(day, 30, current_date())Note:
dbt.date_spine()is not available for all adapters. If the macro isn't supported, use raw SQL withgenerate_seriesor your warehouse's equivalent date generation function instead.
Create models/marts/_models.yml:
models:
- name: time_spine_daily
description: A time spine with one row per day, ranging from 5 years in the past to 30 days into the future.
time_spine:
standard_granularity_column: date_day
columns:
- name: date_day
description: The base date column for daily granularity
granularity: day# Build the time spine table
dbt run --select time_spine_daily
# Preview the model
dbt show --select time_spine_dailyQuery with metrics (if metrics are defined):
# Local development (MetricFlow CLI)
mf validate-configs
mf query --metrics <your_metric> --group-by metric_time
# dbt Studio / dbt Cloud / dbt Cloud CLI
dbt sl query --metrics <your_metric> --group-by metric_timeIf you have an existing date dimension model, configure it as a time spine:
models:
- name: dim_date
description: An existing date dimension model used as a time spine.
time_spine:
standard_granularity_column: date_day
columns:
- name: date_day
granularity: dayCreate models/marts/time_spine_yearly.sql:
{{
config(
materialized = 'table',
)
}}
with years as (
{{
dbt.date_spine(
'year',
"to_date('01/01/2000','mm/dd/yyyy')",
"to_date('01/01/2025','mm/dd/yyyy')"
)
}}
),
final as (
select cast(date_year as date) as date_year
from years
)
select * from final
where date_year >= date_trunc('year', dateadd(year, -4, current_timestamp()))
and date_year < date_trunc('year', dateadd(year, 1, current_timestamp()))Add to _models.yml:
models:
- name: time_spine_yearly
description: Time spine with one row per year
time_spine:
standard_granularity_column: date_year
columns:
- name: date_year
granularity: yearQuery with yearly granularity:
# Local development (MetricFlow CLI)
mf query --metrics orders --group-by metric_time__year
# dbt Studio / dbt Cloud / dbt Cloud CLI
dbt sl query --metrics orders --group-by metric_time__yearCreate models/marts/fiscal_calendar.sql:
with date_spine as (
select
date_day,
extract(year from date_day) as calendar_year,
extract(week from date_day) as calendar_week
from {{ ref('time_spine_daily') }}
),
fiscal_calendar as (
select
date_day,
case
when extract(month from date_day) >= 10
then extract(year from date_day) + 1
else extract(year from date_day)
end as fiscal_year,
extract(week from date_day) + 1 as fiscal_week
from date_spine
)
select * from fiscal_calendarAdd to _models.yml:
models:
- name: fiscal_calendar
description: A custom fiscal calendar with fiscal year and fiscal week granularities.
time_spine:
standard_granularity_column: date_day
custom_granularities:
- name: fiscal_year
column_name: fiscal_year
- name: fiscal_week
column_name: fiscal_week
columns:
- name: date_day
granularity: day
- name: fiscal_year
description: "Custom fiscal year starting in October"
- name: fiscal_week
description: "Fiscal week, shifted by 1 week from standard calendar"Query with fiscal granularity:
# Local development (MetricFlow CLI)
mf query --metrics orders --group-by metric_time__fiscal_year
# dbt Studio / dbt Cloud / dbt Cloud CLI
dbt sl query --metrics orders --group-by metric_time__fiscal_year| Mistake | Fix |
|---|---|
Using semantic_models: instead of time_spine: | Use the time_spine: property under models: |
Missing standard_granularity_column | Required property to tell MetricFlow which column to use |
Missing granularity on columns | Each time column needs a granularity: attribute |
evals
scenarios
dbt-docs-arguments
dbt-docs-unit-test-fixtures
dbt-job-failure
dbt-unit-test-format-choice
example-yaml-error
fusion-migration-triage-basic
fusion-migration-triage-blocked
fusion-triage-cat-a-static-analysis
fusion-triage-cat-b-dict-meta-get
fusion-triage-cat-b-unexpected-config
fusion-triage-cat-b-unused-schema
fusion-triage-cat-b-yaml-syntax
fusion-triage-cat-c-hardcoded-fqn
src
tests
scripts
skills
dbt
skills
adding-dbt-unit-test
references
answering-natural-language-questions-with-dbt
building-dbt-semantic-layer
configuring-dbt-mcp-server
fetching-dbt-docs
scripts
running-dbt-commands
troubleshooting-dbt-job-errors
references
using-dbt-for-analytics-engineering
working-with-dbt-mesh
dbt-extras
skills
creating-mermaid-dbt-dag
dbt-migration
skills
migrating-dbt-core-to-fusion
migrating-dbt-project-across-platforms