Add computed is_measure flag on metric nodes#2336
Merged
Merged
Conversation
✅ Deploy Preview for thriving-cassata-78ae72 canceled.
|
shangyian
force-pushed
the
metric-is-measure
branch
2 times, most recently
from
July 17, 2026 11:46
f9221cd to
c533e52
Compare
A metric is a "measure" when its query is a single aggregation that decomposes into exactly one storable component (SUM, COUNT, MIN, MAX, COUNT(DISTINCT x)) and it does not reference other metrics. Computed on the fly from the metric's expression; not persisted. AVG is NOT a measure: it decomposes into separate SUM and COUNT components, so it cannot map 1:1 to a single column — model it as a derived metric over its own SUM/COUNT measures. Ratios, scaled aggregations, and non-decomposable aggregations (MAX_BY) are likewise not measures. Exposed on the REST metric response (Metric.is_measure) and the GraphQL NodeRevision type (isMeasure). The findNodes loader eager-loads the query column and parents when isMeasure is requested so the field resolves standalone. Only measures can map 1:1 to a column in an externally-built pre-aggregation table (prerequisite for DataJunction#2118). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shangyian
force-pushed
the
metric-is-measure
branch
from
July 17, 2026 12:09
c533e52 to
289968f
Compare
shangyian
marked this pull request as ready for review
July 17, 2026 12:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A metric is a "measure" when its query is a single top-level aggregation call (e.g.,
SUM(x),COUNT(x)) with no cross-measure arithmetic and it does not reference other metrics. Computed on the fly from the metric's expression.Exposed on the REST metric response (
is_measure) and the GraphQL NodeRevision type (isMeasure). ThefindNodesloader eager-loads the query column and parents whenisMeasureis requested so the field resolves standalone.Only measures can map 1:1 to a column in an externally-built pre-aggregation table (prerequisite for #2118).
Test Plan
make checkpassesmake testshows 100% unit test coverageDeployment Plan