Skip to content

Commit

Permalink
add file names for clarity (#5998)
Browse files Browse the repository at this point in the history
this pr adds a `<File name="metricflow_time_spine.sql">` to the code
examples or `<File name="models/model_name.yml">`
  • Loading branch information
mirnawong1 authored Sep 2, 2024
1 parent 80dcf47 commit 2957869
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions website/docs/docs/build/metricflow-time-spine.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Previously, you were required to create a model called `metricflow_time_spine` i

<Lightbox src="/img/time_spines.png" title="Time spine directory structure" />


<File name="models/_models.yml">

```yaml
models:
- name: time_spine_hourly
Expand All @@ -35,6 +36,7 @@ models:
- name: date_day
granularity: day # set granularity at column-level for standard_granularity_column
```
</File>
Now, break down the configuration above. It's pointing to a model called `time_spine_daily`. It sets the time spine configurations under the `time_spine` key. The `standard_granularity_column` is the lowest grain of the table, in this case, it's hourly. It needs to reference a column defined under the columns key, in this case, `date_hour`. Use the `standard_granularity_column` as the join key for the time spine table when joining tables in MetricFlow. Here, the granularity of the `standard_granularity_column` is set at the column level, in this case, `hour`.

Expand Down Expand Up @@ -83,6 +85,8 @@ and date_hour < dateadd(day, 30, current_timestamp())

<VersionBlock firstVersion="1.7">

<File name="metricflow_time_spine.sql">

```sql
{{
config(
Expand Down Expand Up @@ -111,15 +115,17 @@ select * from final
where date_day > dateadd(year, -4, current_timestamp())
and date_hour < dateadd(day, 30, current_timestamp())
```
</File>

</VersionBlock>

</File>

<VersionBlock lastVersion="1.6">

<File name="metricflow_time_spine.sql">

```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 (
Expand All @@ -142,13 +148,15 @@ from final
where date_day > dateadd(year, -4, current_timestamp())
and date_hour < dateadd(day, 30, current_timestamp())
```
</File>

</VersionBlock>

<VersionBlock firstVersion="1.7">

<File name="metricflow_time_spine.sql">

```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 (
Expand All @@ -171,14 +179,14 @@ from final
where date_day > dateadd(year, -4, current_timestamp())
and date_hour < dateadd(day, 30, current_timestamp())
```
</File>

</VersionBlock>

## Hourly time spine
<File name='time_spine_hourly.sql'>

```sql
-- filename: metricflow_time_spine_hour.sql
{{
config(
materialized = 'table',
Expand Down

0 comments on commit 2957869

Please sign in to comment.