Skip to content

feat: add TS.QUERYLABELS support to the timeseries command surface - #4197

Merged
petyaslavova merged 3 commits into
masterfrom
ps_ts_querylabels_support
Jul 20, 2026
Merged

petyaslavova merged 3 commits into
masterfrom
ps_ts_querylabels_support

Conversation

@petyaslavova

@petyaslavova petyaslavova commented Jul 17, 2026 •

Copy link
Copy Markdown
Collaborator

Change summary

This pull request adds support for the TS.QUERYLABELS RedisTimeSeries command
as a new querylabels(label=None, filters=None) method on the shared
TimeSeriesCommands class. Omitting label issues the LABELS form (union of
label names across matching series); passing label issues the VALUES form
(deduplicated values for that label). filters=None queries all indexed series,
while an explicitly empty collection raises DataError. Filters and label are
passed byte-exact, so server-side filter errors surface unchanged as
ResponseError. A parse_query_labels callback normalizes the reply to a
Python list (RESP2 array / RESP3 set) and maps a missing reply to [].

The change is purely additive and, because TimeSeriesCommands is shared, the
single method plus typed @overloads serve both Redis and
redis.asyncio.Redis with aligned sync/async signatures β€” no
backward-compatibility or wire-protocol risk.

Test coverage

New tests in tests/test_timeseries.py and
tests/test_asyncio/test_timeseries.py,
kept in lockstep, cover the LABELS and VALUES forms (with and without
filters), byte-exact values that aren't coerced to numbers, empty results as a
normal success, the DataError for empty filters, and server-side parse
errors surfacing as ResponseError.


Note

Low Risk
Additive TimeSeries API with local validation only; no changes to existing commands or wire behavior for current callers.

Overview
Adds TS.QUERYLABELS to the RedisTimeSeries client as querylabels(label=None, filters=None) on shared TimeSeriesCommands, so sync and async ts() callers get the same API.

label omitted sends the LABELS form (union of label names on matching series). label set sends VALUES (deduplicated values for that label). filters=None queries all indexed series; an empty filters collection raises DataError locally. Filters use the same expressions as queryindex and are passed through verbatim.

parse_query_labels normalizes RESP2 arrays and RESP3 sets to a Python set. The command is wired via QUERYLABELS_CMD in the timeseries module callbacks.

Contributor docs now recommend Iterable[str] for filter arguments that are only iterated. Integration tests (sync + async, Redis β‰₯ 8.9.0) cover LABELS/VALUES modes, iterables, empty results, client validation, and server ResponseError on bad filters.

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

@petyaslavova petyaslavova added the feature New feature label Jul 17, 2026
Comment thread redis/commands/timeseries/commands.py Resolved
Comment thread redis/commands/timeseries/commands.py Resolved
@petyaslavova
petyaslavova force-pushed the ps_ts_querylabels_support branch from 7155c11 to 05d70b9 Compare July 20, 2026 13:19
@petyaslavova
petyaslavova merged commit 459234e into master Jul 20, 2026
730 of 731 checks passed
@petyaslavova
petyaslavova deleted the ps_ts_querylabels_support branch July 20, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants