Replies: 6 comments 12 replies
|
This makes things tricky when trying to compute symmetric aggregates. |
|
@cpimhoff what is the value of having them separate? Is it mainly name-spacing? or is there something semantic? For example, Is there anything different between the results from following 2 examples and your example? Computing in placeAdding a simple metric that is reused |
|
I'm a bit lost here, but is the intention of OSI to support multi-fact metrics (which most BI vendors don't)? |
|
@cpimhoff and others, FYI, This is one of an important discussion points for the metric language working group. We will add a public document with the proposal when it is ready. But also do join the slack workspace to participate in any adhoc discussions. |
|
I agree with treating all of these as Metrics. A Measure looks more like one way to construct a Metric than a separate, peer-level business object. If we keep a flat discriminator, I would call the calculation-plus-filter case A direct classification could be: I would prefer the discriminator name One important constraint is that a filter alone cannot produce a value, so a However, my preferred design is an expression tree rather than introducing a new Metric kind for every combination: In that model, “calculation plus filtering” is simply This structure also scales better. Future operations such as |
|
Wanted to add a concrete data point in favor of keeping the filter separate from the aggregate expression, since the thread has been circling exactly that. We've been evaluating Ossie as the input to a semantic query engine (the engine compiles SQL from the model). A metric shape that comes up constantly for us is "revenue, but only completed orders": an aggregate plus a row-level predicate. With a single SUM(CASE WHEN status = 'COMPLETED' THEN amount ELSE 0 END)That looks equivalent to filtering, but stops being equivalent the moment the metric is grouped by a dimension. Small repro, plain SQL: CREATE TABLE sales(sale_id INT, sale_month TEXT, status TEXT, amount INT);
INSERT INTO sales VALUES
(1,'2024-01','COMPLETED',100),
(2,'2024-01','COMPLETED', 50),
(3,'2024-02','CANCELLED',200), -- Feb has no completed sales
(4,'2024-03','COMPLETED', 70);
-- filter as WHERE, the intended result:
SELECT sale_month, SUM(amount) FROM sales
WHERE status='COMPLETED' GROUP BY sale_month;
-- 2024-01 | 150
-- 2024-03 | 70
-- filter folded into the aggregate, what a single expression forces:
SELECT sale_month, SUM(CASE WHEN status='COMPLETED' THEN amount ELSE 0 END)
FROM sales GROUP BY sale_month;
-- 2024-01 | 150
-- 2024-02 | 0 <-- phantom row
-- 2024-03 | 70The CASE form invents a The root cause is that a row-level filter belongs in the query (WHERE/HAVING at compile time), not inside the aggregate function. Any consumer that compiles a metric's expression into a grouped query inherits this, because the spec gives it no filter to lift out. Which is why I think the direction upthread is right: metrics composing measures + filters, or the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Currently, the OSI only defines “metrics”, which encode top-level calculations across all the datasets in the model.
This is a significant departure from most semantic layers today. Almost all semantic layers define “measures” as a reusable calculation on datasets (Cube, MetricFlow, Malloy, Looker). Some then reserve top level “metrics” (name varies) as a mechanism to specify a particularly interesting aggregation (Cube, MetricFlow, Looker).
For example:
I don’t currently understand the OSI’s rationale for taking such a different approach by encoding all metric and measure definitions at the top level, and I think it is a mistake to call them “metrics” when a formal metric resource would be useful within OSI later on.
All reactions