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 cumulative metrics granularity info #5688

Merged
merged 28 commits into from
Jul 3, 2024

Conversation

mirnawong1
Copy link
Contributor

@mirnawong1 mirnawong1 commented Jun 24, 2024

this pr adds suuport for cumulative metrics granularity options info per notion spec

[x ] Outstanding questions need resolving
[ x] Needs review by PM @Jstein77
[ x] Needs docs review (optional)
[ x] Do not merge yet until dbt core pr is merged

docs project

@mirnawong1 mirnawong1 requested a review from a team as a code owner June 24, 2024 11:56
Copy link

vercel bot commented Jun 24, 2024

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

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2024 5:05pm

@github-actions github-actions bot added content Improvements or additions to content size: medium This change will take up to a week to address Docs team Authored by the Docs team @dbt Labs labels Jun 24, 2024
| `grain_to_date` | Sets the accumulation grain, such as month will accumulate data for one month. Then restart at the beginning of the next. This can't be used with `window`. | Optional |
| `type_param:window` | The accumulation window, such as 1 month, 7 days, 1 year. This can't be used with `grain_to_date`. | Optional |
| `type_param:grain_to_date` | Sets the accumulation grain, such as `month`, which will accumulate data for one month. Then restart at the beginning of the next. This can't be used with `window`. | Optional |
| `type_param:period_agg` | Specifies how to roll up the cumulative metric to another granularity. Options are `start`, `end`, `average`. Defaults to `start` if no `window` is specified. | Optional |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jstein77 I'm not sure I udnerstand the definition? And what does teh start/end/avg mean?

| `type_param:window` | The accumulation window, such as 1 month, 7 days, 1 year. This can't be used with `grain_to_date`. | Optional |
| `type_param:grain_to_date` | Sets the accumulation grain, such as `month`, which will accumulate data for one month. Then restart at the beginning of the next. This can't be used with `window`. | Optional |
| `type_param:period_agg` | Specifies how to roll up the cumulative metric to another granularity. Options are `start`, `end`, `average`. Defaults to `start` if no `window` is specified. | Optional |
| `type_param:window_choice` | Specifies whether to take the cumulative metric value from the beginning (min) or end (max) of the window. Defaults to `min`. | Optional |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jstein77 is this right? and can window_choice and period_agg be used with window and grain_to_date?

website/docs/docs/build/cumulative-metrics.md Outdated Show resolved Hide resolved
website/docs/docs/build/cumulative-metrics.md Show resolved Hide resolved
website/docs/docs/build/cumulative-metrics.md Outdated Show resolved Hide resolved
website/docs/docs/build/cumulative-metrics.md Outdated Show resolved Hide resolved
`period_agg` is set to first so we will choose the first value for the select granularity window. Let's say we cumulative_revenue by week using the following query: `dbt sl query --metrics cumulative_revenue --group-by metric_time__week`.

This compiles the following SQl, Note the use of the window function to select the first value:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jstein77 i'm not sure i understand the diff btw first_value(), etc. here compared to first. but is this placed correctly

Copy link
Contributor

Choose a reason for hiding this comment

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

It's because we use the first_value() function in the generated SQL. We can remove this if it's confusing.

Copy link
Contributor

@nataliefiann nataliefiann left a comment

Choose a reason for hiding this comment

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

Hiya @mirnawong1

Thanks for flagging this. This is amazing! No suggestions or changes from me. Let me know if there's anything else I can do to help on this.

Kind Regards
Natalie

@mirnawong1 mirnawong1 enabled auto-merge (squash) July 3, 2024 16:50
@mirnawong1 mirnawong1 merged commit cffe48e into current Jul 3, 2024
10 of 11 checks passed
@mirnawong1 mirnawong1 deleted the mwong-add-granularity-cumulative-metrics branch July 3, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto update content Improvements or additions to content Docs team Authored by the Docs team @dbt Labs size: large This change will more than a week to address and might require more than one person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants