Skip to content

Add computed is_measure flag on metric nodes#2336

Merged
shangyian merged 1 commit into
DataJunction:mainfrom
shangyian:metric-is-measure
Jul 17, 2026
Merged

Add computed is_measure flag on metric nodes#2336
shangyian merged 1 commit into
DataJunction:mainfrom
shangyian:metric-is-measure

Conversation

@shangyian

Copy link
Copy Markdown
Collaborator

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). 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 #2118).

Test Plan

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

Deployment Plan

@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

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

@shangyian
shangyian force-pushed the metric-is-measure branch 2 times, most recently from f9221cd to c533e52 Compare July 17, 2026 11:46
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
shangyian force-pushed the metric-is-measure branch from c533e52 to 289968f Compare July 17, 2026 12:09
@shangyian
shangyian marked this pull request as ready for review July 17, 2026 12:38
@shangyian
shangyian merged commit d0cc8d4 into DataJunction:main Jul 17, 2026
36 of 37 checks passed
@shangyian
shangyian deleted the metric-is-measure branch July 17, 2026 12:38
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