dbt-labs / dbt-semantic-interfaces

The shared semantic layer definitions that dbt-core and MetricFlow use.
Apache License 2.0
66 stars 13 forks source link

[Feature] Add `default_grain` to metric spec #290

Closed courtneyholcomb closed 2 months ago

courtneyholcomb commented 2 months ago

Is this your first time submitting a feature request?

Describe the feature

Now that we are enabling sub-daily granularities, the current behavior of metric_time will likely be unexpected to users. If they change any of their time dimensions to use a grain smaller than DAY, metric_time will default to that grain. To avoid this confusion, add a parameter that allows users to choose which grain they want their metric to default to. This will default to DAY if not set to avoid the unexpected behavior change. (If DAY is smaller than the defined granularity, will default to the smallest available granularity.)

Describe alternatives you've considered

No response

Who will this benefit?

No response

Are you interested in contributing this feature?

No response

Anything else?

No response

Jstein77 commented 2 months ago

Adding the full metrics spec here. Using cumulative metrics as an example, but default_grain can be defined on any metric.

metrics:
    - name: my_metrics
       type: cumulative
           type_params:
                measure: revenue
       default_grain: day #Optional: defaults to day