Add ClickHouse vector store provider - #7090
Open
MitraShabani wants to merge 1 commit into
Open
Conversation
|
Hi @MitraShabani, thanks for opening this pull request. This is just a soft check: you are not yet in this repo's vouched contributor list ( A maintainer can vouch for you by commenting |
Implements the VectorStoreBase interface for ClickHouse, following the pattern used by the existing Qdrant/Chroma providers. - Add ClickhouseDB in mem0/vector_stores/clickhouse.py - Add ClickhouseConfig in mem0/configs/vector_stores/clickhouse.py - Register clickhouse in factory.py and vector_stores/configs.py - Add clickhouse-connect as an optional dependency - Add tests (tests/vector_stores/test_clickhouse.py) - Add docs page and overview.mdx entry Fixes mem0ai#6991
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the VectorStoreBase interface for ClickHouse, following the pattern used by the existing Qdrant/Chroma providers.
Linked Issue
Closes #6991
Description
Mem0 currently lacks support for ClickHouse as a vector store backend. This PR adds a
ClickhouseDBprovider implementing the fullVectorStoreBaseinterface (create_col, insert, search, delete, update, get, list_cols, delete_col, col_info, list, reset), so users already running ClickHouse for other workloads can use it as their memory backend without standing up a separate vector database.Similarity search uses ClickHouse's built-in
cosineDistance()function, converted to a higher-is-better similarity score as required by the base interface. Deletes and upserts are implemented viaALTER TABLE ... DELETEfollowed by insert, since ClickHouse's MergeTree engine has no native in-place update.Type of Change
AI Assistance
Used Claude interactively throughout — to understand the VectorStoreBase interface and existing provider patterns, to work through implementing and debugging each method, and to diagnose issues (e.g. an async-delete timing race, a dict-vs-object mismatch with mem0's internal result handling). I wrote and tested every method myself against a local ClickHouse instance and understand what each part does and why.
Breaking Changes
N/A — this adds a new optional provider and does not change any existing behavior or interfaces.
Test Coverage
Added
tests/vector_stores/test_clickhouse.pywith 9 tests covering collection creation, insert/get, upsert-not-duplicate behavior, search ranking, delete, update, col_info, and reset. Tests skip automatically if ClickHouse isn't reachable, following the pattern intest_pgvector.py.Also manually verified end-to-end through mem0's public API (
Memory.from_config(...)withprovider: "clickhouse"), using real OpenAI embeddings for bothadd()andsearch()— not just the isolatedClickhouseDBclass.Checklist