Skip to content

docs: document fixed_grain and reaggregate - #2589

Merged
shangyian merged 8 commits into
mainfrom
docs/fixed-grain-and-reaggregate
Sep 25, 2026
Merged

shangyian merged 8 commits into
mainfrom
docs/fixed-grain-and-reaggregate

Conversation

@shangyian

@shangyian shangyian commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add documentation for share-of-total metrics and semi-additive measures.

Test Plan

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

Deployment Plan

Neither declaration was covered for modelers. `fixed_grain` appeared only
as a one-line table row in the YAML reference, and `reaggregate` was absent
entirely -- the word appears in the internals doc meaning something else
(re-aggregating to a coarser grain for windows), which made the gap easy to
miss.

The share-of-total section was also out of date. It told readers to hardcode
a category per metric or divide in their application code, which `fixed_grain:
[]` now does natively. It is rewritten around the feature, keeping a narrowed
pointer to #1695 for the case still unsupported: a numerator and denominator
needing different grains from the same fanned fact.

Both sections record the behaviour that is hard to guess from the feature
names. A fixed grain broadcasts an aggregate but does not deduplicate one, so
on a parent that repeats an entity across the dimension being sliced the inner
aggregate overcounts and the partition sums the overcount. A reaggregate rule
collapses a dimension but does not build a window, so it cannot turn daily
flags into a distinct count over a trailing window.

Examples use the existing default.sales and snapshot vocabulary. Every
behavioural claim, including the emitted SQL shapes, was checked against a
running server rather than read off the source.
@netlify

netlify Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for thriving-cassata-78ae72 ready!

Name Link
🔨 Latest commit b37c580
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6ab6dfb684d68c00087863ae
😎 Deploy Preview https://deploy-preview-2589--thriving-cassata-78ae72.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

The node config examples on the metrics page were API payloads, while
nodes are mostly authored as YAML. Converts all six, including the three
that predate this branch, so the page is one format throughout rather
than split by which section you land on.

The nested reaggregate rules in particular read better without the
braces and quotes.
Two rules on fixed_grain's dimension list were documented that DJ already
raises clear errors for -- one tells you to add the dimension to the query,
the other suggests a global grain outright. You meet both at the moment
they matter, already solved.

What stays is what fails quietly: a fixed grain broadcasting an overcount
rather than deduplicating, and a reaggregate rule being mistaken for a
window. Neither raises anything; both return a plausible wrong number.

Also drops the difficulty framing from the share-of-total opener and a
line about list order that carried nothing.
The warning explained the double aggregation in the abstract, which is
hard to follow at the moment you need it. Replaced with three rows of
data where the wrong answer is visible: two accounts, sliced by device,
summing to three.

Also repoints the tracking link. #1695 was superseded by #2245, which
opens by reframing it and covers off-query-grain metrics generally --
including the case this warning describes.
Three passages in the semi-additive section read as reassurance rather
than description -- 'still works as expected', 'behaves like any other
metric', 'answer the question correctly instead of refusing it'. A reader
wants the result, not confidence that the result is right.

Each now states the output: what slicing returns, what a query with the
dimension in the grain returns, and what the two options give back when
a query omits the dimension.
The heading carried two sentences, one of which only set up the other.
Since required_dimensions is documented further down the same page, a
reader may wonder why not use that instead -- so the distinction stays,
as a sentence linking to it, without a section around it.
The warning said a semi-additive metric cannot be queried alongside a
plain additive one from the same parent. Two things wrong with that: the
shared parent is irrelevant, and the restriction is conditional.

_validate_reaggregate_base_group_join_safety fires only when a query
produces multiple grain groups and one of them is semi-additive. Include
the collapsed dimension in the output grain and both metrics land in the
same group, which compiles fine -- verified against a running server, not
inferred from the one query that happened to fail.
The grain-group warning existed to compensate for an unhelpful error
message. The message is the thing to fix; a docs entry restating it is
not. Removed, and the error text is worth improving separately so it
names the remedy.

The remaining note was written in vocabulary from the investigation
behind these docs -- daily flags, trailing windows, distinct counts --
none of which appears on this page. It now says the thing plainly: a
rule picks a value along the dimension, it does not combine values
across it.
@shangyian shangyian changed the title docs: document fixed_grain and reaggregate docs: document fixed_grain and reaggregate Sep 25, 2026
@shangyian
shangyian marked this pull request as ready for review September 25, 2026 21:00
@shangyian
shangyian merged commit ae62cd3 into main Sep 25, 2026
23 checks passed
@shangyian
shangyian deleted the docs/fixed-grain-and-reaggregate branch September 25, 2026 23:18
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.

1 participant