Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time spine move from dbt-utils to dbt-core #4263

Merged
merged 9 commits into from
Oct 12, 2023
68 changes: 68 additions & 0 deletions website/docs/docs/build/metricflow-time-spine.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To create this table, you need to create a model in your dbt project called `met

<File name='metricflow_time_spine.sql'>

<VersionBlock lastVersion="1.6">

```sql
{{
config(
Expand All @@ -38,8 +40,45 @@ final as (

select * from final
```

</VersionBlock>

<VersionBlock firstVersion="1.7">

```sql
{{
config(
materialized = 'table',
)
}}

with days as (

{{
dbt.date_spine(
dbeatty10 marked this conversation as resolved.
Show resolved Hide resolved
dbt.date_spine(
'day',
"to_date('01/01/2000','mm/dd/yyyy')",
"to_date('01/01/2027','mm/dd/yyyy')"
)
}}

),

final as (
select cast(date_day as date) as date_day
from days
)

select * from final
```

</VersionBlock>

</File>

<VersionBlock lastVersion="1.6">

```sql
-- filename: metricflow_time_spine.sql
-- BigQuery supports DATE() instead of TO_DATE(). Use this model if you're using BigQuery
Expand All @@ -61,4 +100,33 @@ final as (
select *
from final
```

</VersionBlock>

<VersionBlock firstVersion="1.7">

```sql
-- filename: metricflow_time_spine.sql
-- BigQuery supports DATE() instead of TO_DATE(). Use this model if you're using BigQuery
{{config(materialized='table')}}
with days 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 days
)

select *
from final
```

</VersionBlock>

You only need to include the `date_day` column in the table. MetricFlow can handle broader levels of detail, but it doesn't currently support finer grains.
Loading