refactor(types): split ExactKind::MinMax into Min and Max - #407
Merged
Conversation
`ExactKind::MinMax` was never a min/max pair: `function_rules` maps `AggIntent::Max` onto it and `AggIntent::Min` onto the separately added `ExactKind::Min`, so the name promised a two-sided accumulator that the variant never was. Consumers that match on the family had to carry the direction out-of-band (ASAPQuery-backend threads it through the `aggregationSubType` wire string) because the name gave no guarantee about which extremum the state holds. Rename the variant to `Max` in both `ExactKind` and `ExactParams`, so the two directions are symmetric variants and a stored minimum can no longer content-address onto a maximum. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Lowering `count(v)` to a row count (15e6cf8) matched PromQL, but it left no way to ask for a distinct count that reduces across series. The `Cardinality` intent survived only under `distinct_over_time(v[w])`, which is per-series: a consumer holding one mergeable cardinality state per source could answer the merged question and had no expression that asked it. Collapse `count(distinct_over_time(v[w]))` into a single `Aggregate{[Cardinality]}` reduced by the outer `by`. The nested reading -- count the series that have a distinct-count -- is not what anyone writes this expression for, and it discards the mergeability of the state underneath. The collapsed form needs its own reduction rule: `reduction_for` reads the surviving `TimeRange` as one row per series and answers `PerEntity`, which is right for a bare `distinct_over_time(v[w])` and wrong once an explicit aggregator wraps it. `windowed_reduce` keeps the outer aggregator's grouping, so an empty `by` reduces everything. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The exact maximum accumulator was named
MinMax, while minimum already usedMin. RenameExactKind::MinMaxandExactParams::MinMaxtoMax, updating mapping, schema, accuracy provenance, and tests.Before this PR: the maximum family used the ambiguous
MinMaxname.After this PR: minimum and maximum have explicit
Min/Maxvariants. Nestedcount(distinct_over_time(...))retains an outer Count over per-series Cardinality. For one series with samples[1, 2], the inner result is 2 and the outer count is 1. Regression coverage preserves both levels and grouping for ungrouped andby (job)queries.Verification: 187 PromQL frontend tests passed; frontend all-target Clippy with
-D warnings, formatting, and diff checks passed. A focused nested-count regression failed against the previous PR head before the correction. Production backend execution was not run for this update.Base and compatibility: stacked on
feat/current-series-rules, notmain. The public enum rename requires downstream consumers to update their references and serialized contracts together.