Skip to content

feat(time-series): support multiple aggregators per key in TS.NRANGE/TS.NREVRANGE - #3360

Open
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:fix-nrange
Open

feat(time-series): support multiple aggregators per key in TS.NRANGE/TS.NREVRANGE#3360
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:fix-nrange

Conversation

@nkaradzhov

@nkaradzhov nkaradzhov commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

This pull request updates TS.NRANGE and TS.NREVRANGE to support multiple aggregators per key, matching the semantics finalized in RedisTimeSeries#2079 (merged Jul 2) and the updated HLD.

Background

The originally merged implementation (#3337) exposed a typed API that accepted only one aggregator per key (AGGREGATION.types was a flat TimeSeriesAggregationTypeList, one entry per key, emitted as separate tokens). The server and HLD now define one aggregation token per key, where each token may hold multiple comma-separated aggregators — e.g. AGGREGATION avg,max sum 1000 gives key 1 both avg and max, key 2 sum. The merged wire format was still valid, but the typed API could not express the multi-aggregator case.

Changes

  • NRANGE.ts: AGGREGATION.types changes from TimeSeriesAggregationTypeList to a new TimeSeriesAggregationTypeGroups — an array of per-key groups ([TimeSeriesAggregationTypeList, ...TimeSeriesAggregationTypeList[]]). Each group is emitted as a single comma-joined token (group.join(',')).
  • NREVRANGE.ts: unchanged — reuses NRANGE's parser.
  • The shared TimeSeriesAggregationTypeList (used by single-key TS.RANGE) is deliberately left untouched.
  • Specs updated to the grouped shape; added arg + behavior tests for the multiple-aggregators-per-key case.

Compatibility

This is a breaking change to the typed API introduced in #3337. Existing callers using the flat form (types: [MAX, MIN]) must migrate to the grouped form (types: [[MAX], [MIN]]). The generated wire output for single-aggregator-per-key usage is unchanged, so no server-side behavior regresses. Since #3337 is unreleased, this only affects branch/edge consumers.

🤖 Generated with Claude Code


Note

Medium Risk
Breaking change to an unreleased typed API; wire format for one aggregator per key is preserved, but misuse of the new nested shape could send invalid AGGREGATION arguments.

Overview
AGGREGATION.types for TS.NRANGE / TS.NREVRANGE is now an array of per-key aggregator groups (e.g. [[MAX], [MIN]] or [[MIN, MAX], [SUM]]) instead of a flat one-aggregator-per-key list. Each group is serialized as a single comma-joined token on the wire (MIN,MAX, SUM), aligning with RedisTimeSeries#2079.

Callers who used the previous flat shape must wrap each aggregator in its own inner array; single-aggregator-per-key wire output is unchanged. NREVRANGE picks up the behavior via the shared NRANGE argument parser. Specs add transform and integration coverage for multi-aggregator-per-key cases.

Reviewed by Cursor Bugbot for commit e959ff0. Bugbot is set up for automated code reviews on this repo. Configure here.

…TS.NREVRANGE

RedisTimeSeries#2079 finalized the semantics: one AGGREGATION token per key,
each holding one or more comma-separated aggregators (e.g. `avg,max sum`). The
merged implementation (redis#3337) only exposed a single aggregator per key.

Change `AGGREGATION.types` from a flat `TimeSeriesAggregationTypeList` to
`TimeSeriesAggregationTypeGroups` (one group per key); emit each group as a
single comma-joined token. The shared `TimeSeriesAggregationTypeList` used by
single-key TS.RANGE is left untouched.

BREAKING (vs unreleased redis#3337): flat `types: [MAX, MIN]` becomes grouped
`types: [[MAX], [MIN]]`. Wire output for single-aggregator usage is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nkaradzhov
nkaradzhov requested a review from PavelPashov July 24, 2026 07:56
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