Skip to content

feat(time-series): add EXCLUDEEMPTY to TS.MRANGE and TS.MREVRANGE#3352

Open
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:excludeempty
Open

feat(time-series): add EXCLUDEEMPTY to TS.MRANGE and TS.MREVRANGE#3352
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:excludeempty

Conversation

@nkaradzhov

@nkaradzhov nkaradzhov commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

This pull request adds support for the EXCLUDEEMPTY flag on TS.MRANGE and TS.MREVRANGE, introduced in Redis 8.10. When set, the server omits from the top-level reply any matching time series whose samples array is empty for the queried range and options. The default behavior (empty series included) is unchanged and fully backward compatible.

The flag is exposed as an EXCLUDEEMPTY?: boolean option on the non-GROUPBY multi-range helpers (base, WITHLABELS, SELECTED_LABELS, and their multi-aggregation counterparts), for both forward (mRange) and reverse (mRevRange) commands. It is emitted as a bare flag with no value, placed among the range options before FILTER.

Key design points:

  • EXCLUDEEMPTY lives on new TsMRangeOptions / TsMRangeMultiAggrOptions types, so single-key TS.RANGE/TS.REVRANGE never offer an invalid option.
  • EXCLUDEEMPTY is mutually exclusive with GROUPBY. Because GROUPBY is a separate set of command variants that do not expose the option, the illegal combination is unrepresentable in the typed API. Raw sendCommand users who combine them still receive the server error (TSDB: EXCLUDEEMPTY is not allowed with GROUPBY) unchanged.
  • The response parser is unchanged — the server simply returns fewer entries. No client-side filtering, no extra commands, routing unchanged.

Behavior tests are gated to server >= 8.10.

🤖 Generated with Claude Code


Note

Low Risk
Read-only command argument and typing changes with default behavior unchanged; no reply parsing or security-sensitive logic.

Overview
Adds Redis 8.10 EXCLUDEEMPTY support on non-GROUPBY TS.MRANGE / TS.MREVRANGE client helpers so callers can omit matching series with no samples in the queried range.

The option is EXCLUDEEMPTY?: boolean on new TsMRangeOptions and TsMRangeMultiAggrOptions (extending the existing range option types so single-key TS.RANGE does not expose it). parseExcludeEmptyArgument emits the bare EXCLUDEEMPTY token after range options and before FILTER / label modifiers across base, WITHLABELS, SELECTED_LABELS, and multi-aggregation parsers. Reply handling is unchanged; the server returns fewer keys.

Tests cover argument serialization for several variants and integration checks on mRange / mRevRange (gated to server ≥ 8.10).

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

Adds the Redis 8.10 EXCLUDEEMPTY flag to the non-GROUPBY TS.MRANGE and
TS.MREVRANGE variants (base, WITHLABELS, SELECTED_LABELS, and their
multi-aggregation counterparts), for both forward and reverse commands.

When set, the server omits matching series with an empty samples array
from the top-level reply. Default behavior is unchanged.

The flag lives on new TsMRangeOptions / TsMRangeMultiAggrOptions types so
single-key TS.RANGE/TS.REVRANGE never expose it. GROUPBY variants also do
not expose it, making the illegal EXCLUDEEMPTY+GROUPBY combination
unrepresentable in the typed API while raw commands still surface the
server error. The response parser is unchanged.

Behavior tests gated to server >= 8.10.

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