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

add custom granularities to mf timespine #6145

Open
wants to merge 9 commits into
base: current
Choose a base branch
from

Conversation

mirnawong1
Copy link
Contributor

@mirnawong1 mirnawong1 commented Sep 25, 2024

this pr adds the new custom_granularities feature to the mf timespine doc. this also includes a release note

Resolves #6075

@mirnawong1 mirnawong1 requested a review from a team as a code owner September 25, 2024 11:48
Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview Sep 26, 2024 5:13pm

@github-actions github-actions bot added content Improvements or additions to content Docs team Authored by the Docs team @dbt Labs size: medium This change will take up to a week to address labels Sep 25, 2024
time_spine:
standard_granularity_column: date_day
custom_granularities:
- name: fiscal_year
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presume this is case sensitive, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea it should be lowercase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec looks good but linking back to the source of truth just to be safe: dbt-labs/dbt-semantic-interfaces#338 (comment)


To use a custom calendar model, ensure it meets the following requirements:

- The model must be at a daily grain and joinable to other date columns using `date_day`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a requirement, you could use a dim date table at an hourly grain and define custom granularities for that model.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ you can use any of our standard granularities!


- The model must be at a daily grain and joinable to other date columns using `date_day`.
- Columns must align with expected data types for a given granularity (for example, `quarter` should be a date).
- Support period-over-period calculations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a requirement of the model, it's a requirement of for the functionality we support. We can remove it.

- The model must be at a daily grain and joinable to other date columns using `date_day`.
- Columns must align with expected data types for a given granularity (for example, `quarter` should be a date).
- Support period-over-period calculations.
- Support cumulative metric windows using custom granularities (for example, cumulative fiscal year-to-date bookings).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above, this is a requirement for us, not the underlying model

```yaml
models:
- name: my_time_spine
description: "my favorite time spine"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to wrap this in quotes

Copy link
Contributor

@Jstein77 Jstein77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments but looks really solid!


#### Configuring time-spine
### Configuring time-spine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we use "time-spine" instead of just "time spine"? Curious if @Jstein77 has an opinion on this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was originally using time spine but then saw it used with a dash and thought/assumed i had a wrong. happy with time spine too! @Jstein77 are we good with time spine?


#### Understanding time-spine and granularity
The previous configuration demonstrates a time-spine 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`. Additionally, the `custom_granularities` field lets you specify non-standard time periods like `fiscal_year` or `retail_month` that your organization may use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of:
"The standard_granularity_column is the lowest grain of the table, in this case, it's hourly."
Can we say:
The standard_granularity_column is the column that maps to one of our standard granularities [list or link to options here]. The grain of this column must be finer or equal in size to the granularity of all custom granularity columns in the same model. In this case, it's hourly.
Slightly more accurate!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not: when referencing the columns key, can we put that in quotes like the other keys referenced?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of:
"Use the standard_granularity_column as the join key for the time spine table when joining tables in MetricFlow."
"MetricFlow will use the standard_granularity_column as the join key when joining the time spine table to other source table."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And one more thing - can we gate anything that references custom granularities on version 1.9+? Or add a note about upgrading like you did in the custom calendar section.


To use a custom calendar model, ensure it meets the following requirements:

- The model must be at a daily grain and joinable to other date columns using `date_day`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ you can use any of our standard granularities!

To use a custom calendar model, ensure it meets the following requirements:

- The model must be at a daily grain and joinable to other date columns using `date_day`.
- Columns must align with expected data types for a given granularity (for example, `quarter` should be a date).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this to be a little more specific:
"The standard_granularity_column must be a date time type."
(Or something similar - datetime/date/timestamp I think are all fine but not sure if I'm missing options from any specific engines)
Also could move that note to the section about standard_granularity_column.
The other columns can be any type so I don't think we need to add any detail about that.

@courtneyholcomb
Copy link
Contributor

Also wondering if we should add a not about features that are upcoming but not supported yet, like calculating offsets / period over period. Might be helpful to get ahead of those questions. @Jstein77 thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content Docs team Authored by the Docs team @dbt Labs size: medium This change will take up to a week to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Core] Docs Changes Needed from dbt-core Issue #9265
3 participants