Proposal: metric additivity (additive / semi-additive / non-additive) in the core spec #465
harrydevforlife
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
Thanks! The expression language working group has discussed this a little bit, but not come to any conclusions. We'd definitely appreciate input here. Another open question I'd be interested in is what happens when there is a conflict, e.g. the expression is a I've worked on Databricks' feature in this space ("window measures"). It takes the approach that the query engine analyzes the expression to determine additivity, rather than having it be separate metadata. This avoids the potential for a conflict, but requires a library that can parse the analyze Ossie expressions. (Maybe such a library should be part of the Ossie repository?) |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
In the current core spec (
core-spec/spec.md), a metric is onlyname,expression,description,datatype,ai_contextandcustom_extensions. There is no way to declare how a metric may be aggregated across dimensions.For fully additive metrics (
SUM(revenue)) and clearly non-additive ones (COUNT(DISTINCT user_id), ratios) a consumer can often infer behaviour from the expression. But semi-additive metrics cannot be inferred:SUM(balance), inventory levels, or daily-active snapshots are summable across users/regions but must not be summed across time (you want last / first / average over the period instead). Today the only options are vendor-specificcustom_extensionsorai_contexthints, neither of which is portable or enforceable by query engines.Proposal
Add optional, portable additivity metadata to the Metric object, e.g.:
Prior art: dbt/MetricFlow
non_additive_dimension(withwindow_choiceandwindow_groupings), Cube, SSAS semi-additive measures (LastNonEmpty, etc.).Open questions
additivitybe explicit, or derived fromnon_additive_dimensionsbeing present?is_timefields and time-grain handling?Happy to help draft a PR if there is interest.
All reactions