Skip to content

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

Draft
petyaslavova wants to merge 1 commit intomasterfrom
ps_add_count_aggregator_to_sorted_set_commands
Draft

Adding support for new COUNT aggregator for some sorted set commands - ZINTER, ZINTERSTORE, ZUNION, ZUNIONSTORE#4034
petyaslavova wants to merge 1 commit intomasterfrom
ps_add_count_aggregator_to_sorted_set_commands

Conversation

@petyaslavova
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.

@jit-ci
Copy link
Copy Markdown

jit-ci bot commented Apr 16, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

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