Skip to content

Conversation

@tanujnay112
Copy link
Contributor

@tanujnay112 tanujnay112 commented Dec 5, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Allow get_statistics to take in multiple filter keys
  • New functionality
    • ...

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Dec 5, 2025

Enable multi-key filtering in get_statistics

The PR updates chromadb/utils/statistics.py to replace the single-key filter parameter with a keys list for multi-key filtering. It augments the filtering logic to issue a $in query including summary and adds a safeguard that raises ValueError when more than 30 keys are provided. The distributed statistics wrapper tests are adjusted to use the new keys argument.

Overall, the change introduces a new calling signature for get_statistics while keeping pagination and summary handling intact.

Key Changes

• Replaced the key parameter in get_statistics with keys: Optional[List[str]] and updated docstrings
• Added a MAX_KEYS = 30 guard that raises ValueError when the key list exceeds the limit
• Switched where_filter construction to use $in queries including summary when filtering
• Updated distributed statistics wrapper tests to pass keys=[...]

Affected Areas

chromadb/utils/statistics.py
chromadb/test/distributed/test_statistics_wrapper.py

This summary was automatically generated by @propel-code-bot

Comment on lines +185 to +190
if keys is not None and len(keys) > MAX_KEYS:
raise ValueError(
f"Too many keys provided: {len(keys)}. "
f"Maximum allowed is {MAX_KEYS} keys per request. "
"Consider calling get_statistics multiple times with smaller key batches."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Important

[Testing] This is a great safeguard to prevent overly large queries. To ensure this new validation is covered, could you please add a test case to chromadb/test/distributed/test_statistics_wrapper.py that asserts a ValueError is raised when more than 30 keys are provided?

Context for Agents
This is a great safeguard to prevent overly large queries. To ensure this new validation is covered, could you please add a test case to `chromadb/test/distributed/test_statistics_wrapper.py` that asserts a `ValueError` is raised when more than 30 keys are provided?

File: chromadb/utils/statistics.py
Line: 190

Copy link
Contributor

@kylediaz kylediaz left a comment

Choose a reason for hiding this comment

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

let's gooo

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.

3 participants