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

[CT-1091] [Feature] Add Lookback Attribute for Metrics #5721

Closed
3 tasks done
callum-mcdata opened this issue Aug 26, 2022 · 3 comments · Fixed by #5722
Closed
3 tasks done

[CT-1091] [Feature] Add Lookback Attribute for Metrics #5721

callum-mcdata opened this issue Aug 26, 2022 · 3 comments · Fixed by #5722
Labels
enhancement New feature or request semantic Issues related to the semantic layer
Milestone

Comments

@callum-mcdata
Copy link
Contributor

callum-mcdata commented Aug 26, 2022

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

The metrics package is looking to expand the types of metrics that it can operate on and one consistent piece of feedback we've received is that people want to be able to define metrics that have a concept of time included in their definition. IE 14 Day Average, etc.

This functionality has an open PR here for the metrics package. We've proven that it works but want to move the definition of this metric aspect into the metric itself instead of meta.

Example:

metrics:
  - name: base_lookback_metric
    model: ref('fact_orders')
    label: Total Discount ($)
    timestamp: order_date
    time_grains: [day, week, month]
    type: sum
    sql: discount_total
    dimensions:
      - had_discount
      - order_country
      
    window: 14 days
   

Describe alternatives you've considered

Not including it.

Who will this benefit?

Anyone who wants to use metrics that are cumulative or lookback.

Are you interested in contributing this feature?

Yep!

Anything else?

I am not married or even really attached to the name of lookback. It is a placeholder while we work on the functionality.

@callum-mcdata callum-mcdata added enhancement New feature or request triage labels Aug 26, 2022
@github-actions github-actions bot changed the title [Feature] Add Lookback Attribute for Metrics [CT-1091] [Feature] Add Lookback Attribute for Metrics Aug 26, 2022
@jtcohen6 jtcohen6 added this to the v1.3 milestone Aug 29, 2022
@jtcohen6 jtcohen6 removed the triage label Aug 29, 2022
@jtcohen6
Copy link
Contributor

Thanks for the issue and the PR @callum-mcdata! Adding support for rolling lookback windows is cool and good. Let's add this into the v1.3 initiative around improvements to metrics.

Very open to suggestions from the world (or just @dbeatty10) about what we'll want to call this thing. I don't mind lookback personally.

@dbeatty10
Copy link
Contributor

Love any opportunity for a good brainstorming session!

Some quick ideas for nomenclature:

lookback
window
offset
lead/lag
start/end
window_bounds

Some of these might be able to be dismissed quickly.

window is probably my favorite so far. Not because I've spent a sufficient amount of time understanding the context though! 😅 Mainly because after some brief googling, learned that window is the only required parameter of Series.rolling() within Pandas (which return Rolling objects that support a variety of aggregation functions). Learn more here.

Example usage:

In[1]: 
s = pd.Series(range(5))

s.rolling(window=2).sum()
Out[2]: 
0    NaN
1    1.0
2    3.0
3    5.0
4    7.0
dtype: float64

@callum-mcdata
Copy link
Contributor Author

I think @dbeatty10 convinced me that window is a better descriptor of what we're working with.

@jtcohen6 jtcohen6 added the semantic Issues related to the semantic layer label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semantic Issues related to the semantic layer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants