From 0e24f55539383029ec55fe985085e563677a57d9 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Wed, 11 Oct 2023 20:13:04 -0400 Subject: [PATCH 1/4] Time spine move from dbt-utils to dbt-core --- website/docs/docs/build/metricflow-time-spine.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/docs/build/metricflow-time-spine.md b/website/docs/docs/build/metricflow-time-spine.md index 254fa3cc5f0..2653e98601b 100644 --- a/website/docs/docs/build/metricflow-time-spine.md +++ b/website/docs/docs/build/metricflow-time-spine.md @@ -22,7 +22,7 @@ To create this table, you need to create a model in your dbt project called `met with days as ( {{ - dbt_utils.date_spine( + dbt_core.date_spine( 'day', "to_date('01/01/2000','mm/dd/yyyy')", "to_date('01/01/2027','mm/dd/yyyy')" @@ -45,7 +45,7 @@ select * from final -- BigQuery supports DATE() instead of TO_DATE(). Use this model if you're using BigQuery {{config(materialized='table')}} with days as ( - {{dbt_utils.date_spine( + {{dbt_core.date_spine( 'day', "DATE(2000,01,01)", "DATE(2030,01,01)" From d9382272a6f64d8ebe7179dc50fd5d30d1a062b5 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:15:03 -0400 Subject: [PATCH 2/4] Apply suggestions from code review --- website/docs/docs/build/metricflow-time-spine.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/docs/build/metricflow-time-spine.md b/website/docs/docs/build/metricflow-time-spine.md index 2653e98601b..e7616c1c44a 100644 --- a/website/docs/docs/build/metricflow-time-spine.md +++ b/website/docs/docs/build/metricflow-time-spine.md @@ -22,7 +22,7 @@ To create this table, you need to create a model in your dbt project called `met with days as ( {{ - dbt_core.date_spine( + dbt.date_spine( 'day', "to_date('01/01/2000','mm/dd/yyyy')", "to_date('01/01/2027','mm/dd/yyyy')" @@ -45,7 +45,7 @@ select * from final -- BigQuery supports DATE() instead of TO_DATE(). Use this model if you're using BigQuery {{config(materialized='table')}} with days as ( - {{dbt_core.date_spine( + {{dbt.date_spine( 'day', "DATE(2000,01,01)", "DATE(2030,01,01)" From c894c90321c4d53543bdad9f185d6cc006804f22 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Thu, 12 Oct 2023 16:07:10 -0400 Subject: [PATCH 3/4] Adding version blocks --- .../docs/docs/build/metricflow-time-spine.md | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/website/docs/docs/build/metricflow-time-spine.md b/website/docs/docs/build/metricflow-time-spine.md index 2653e98601b..997d85e38a8 100644 --- a/website/docs/docs/build/metricflow-time-spine.md +++ b/website/docs/docs/build/metricflow-time-spine.md @@ -12,6 +12,39 @@ To create this table, you need to create a model in your dbt project called `met + + +```sql +{{ + config( + materialized = 'table', + ) +}} + +with days as ( + + {{ + dbt_utils.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 +``` + + + + + ```sql {{ config( @@ -22,7 +55,7 @@ To create this table, you need to create a model in your dbt project called `met with days as ( {{ - dbt_core.date_spine( + dbt.date_spine( 'day', "to_date('01/01/2000','mm/dd/yyyy')", "to_date('01/01/2027','mm/dd/yyyy')" @@ -38,14 +71,45 @@ final as ( select * from final ``` + + + + + +```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_utils.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 +``` + + + + + ```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_core.date_spine( + {{dbt.date_spine( 'day', "DATE(2000,01,01)", "DATE(2030,01,01)" @@ -61,4 +125,7 @@ final as ( select * from final ``` + + + 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. From e4a052fe6abe6455beefa37e18634e5f22b8eddb Mon Sep 17 00:00:00 2001 From: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:04:49 -0600 Subject: [PATCH 4/4] Remove duplicated line --- website/docs/docs/build/metricflow-time-spine.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/docs/docs/build/metricflow-time-spine.md b/website/docs/docs/build/metricflow-time-spine.md index 7b67868cafd..997d85e38a8 100644 --- a/website/docs/docs/build/metricflow-time-spine.md +++ b/website/docs/docs/build/metricflow-time-spine.md @@ -55,7 +55,6 @@ select * from final with days as ( {{ - dbt.date_spine( dbt.date_spine( 'day', "to_date('01/01/2000','mm/dd/yyyy')",