Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding support for new COUNT aggregator for some sorted set commands - ZINTER, ZINTERSTORE, ZUNION, ZUNIONSTORE#4034

Merged
petyaslavova merged 3 commits into
masterfrom
ps_add_count_aggregator_to_sorted_set_commands
Apr 21, 2026
Merged

Adding support for new COUNT aggregator for some sorted set commands - ZINTER, ZINTERSTORE, ZUNION, ZUNIONSTORE#4034
petyaslavova merged 3 commits into
masterfrom
ps_add_count_aggregator_to_sorted_set_commands

Conversation

@petyaslavova

@petyaslavova petyaslavova commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Add COUNT aggregator support for sorted set commands (ZINTER, ZINTERSTORE, ZUNION, ZUNIONSTORE)

This PR adds support for the new COUNT aggregation mode introduced in Redis 8.8.0 for sorted set aggregate commands: ZINTER, ZINTERSTORE, ZUNION, and ZUNIONSTORE. The COUNT aggregator ignores original element scores and instead counts weighted set membership — each element's resulting score is the sum of the weights of the input sets that contain it. When all weights are 1 (the default), the score simply equals the number of input sets containing the element.

The implementation updates the _zaggregate helper in redis/commands/core.py to accept "COUNT" as a valid aggregate option alongside the existing SUM, MIN, and MAX modes.
The error message for invalid aggregate values has been updated accordingly.
Docstrings for zinter, zinterstore, zunion, and zunionstore have been expanded to document all four aggregation modes with clear descriptions and score formulas.

Comprehensive tests have been added across all test suites — sync, async, sync cluster, and async cluster — covering both basic COUNT aggregation and COUNT with custom weights.


Note

Low Risk
Small, localized change to argument validation for sorted-set aggregate commands plus new tests; low risk aside from potential compatibility differences on older Redis versions (tests are version-gated).

Overview
Adds support for the new COUNT AGGREGATE mode for sorted-set aggregate commands by allowing COUNT in the internal _zaggregate command builder (and updating the invalid-aggregate DataError message).

Updates docstrings for zinter, zinterstore, zunion, and zunionstore to document COUNT semantics and formulas, and adds version-gated tests (sync/async, cluster/non-cluster) covering COUNT behavior with and without weights.

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

@jit-ci

jit-ci Bot commented Apr 16, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@petyaslavova petyaslavova marked this pull request as ready for review April 20, 2026 16:19

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 130f52a. Configure here.

Comment thread tests/test_commands.py
@petyaslavova petyaslavova merged commit fb38279 into master Apr 21, 2026
279 of 280 checks passed
@petyaslavova petyaslavova deleted the ps_add_count_aggregator_to_sorted_set_commands branch April 21, 2026 09:39
@petyaslavova petyaslavova added the feature New feature label Apr 24, 2026
petyaslavova added a commit that referenced this pull request May 26, 2026
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