Skip to content

feat: fixed_grain for level metrics - #2567

Merged
shangyian merged 10 commits into
mainfrom
robind/fixed-grain
Sep 24, 2026
Merged

shangyian merged 10 commits into
mainfrom
robind/fixed-grain

Conversation

@betodealmeida

Copy link
Copy Markdown
Member

Summary

A rebase of @robinld's #2532 onto my PR #2502 after I addressed all the comments from @shangyian and @robinld.

Test Plan

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

@betodealmeida
betodealmeida marked this pull request as ready for review September 23, 2026 13:38
@betodealmeida
betodealmeida force-pushed the robind/fixed-grain branch 2 times, most recently from c361187 to cb505e0 Compare September 23, 2026 16:29
Base automatically changed from semi-additive-metrics to main September 23, 2026 21:25
Robin Davis and others added 9 commits September 23, 2026 18:26
An experimentation metric is a ratio of two unit-grain metrics: the
activity each allocated unit contributed, over the allocated population.
Writing that shape down here records where this branch stops.

Two refusals land on the shape rather than on an edge case. A population
written as COUNT(DISTINCT unit) at unit grain is refused, though at unit
grain the count is one per unit and the merge is a plain sum. And the
ratio always spans two facts, since the population comes from the
allocation table, so the cross-fact refusal applies to every one of
these metrics.

The global grain the refusal suggests does build, and answers a
different question: OVER () broadcasts the total across every group, so
the result divides an all-time total by one month's population.

The last test is xfail rather than an assertion on the generated SQL. A
fixed-grain dimension outside the query grain never reaches the measures
CTE, so the window partitions by a column that does not exist. Pinning
that SQL would lock in something no engine accepts, so it asserts only
the invariant: a column read from a CTE has to be projected by it.
@netlify

netlify Bot commented Sep 23, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit b44462a
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6ab452970f58890008cf2ae8

@shangyian

Copy link
Copy Markdown
Collaborator

Exciting! Going to merge so we can release 🎉

@shangyian
shangyian merged commit 5d1540b into main Sep 24, 2026
32 checks passed
@shangyian
shangyian deleted the robind/fixed-grain branch September 24, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants