Skip to content

Add ClickHouse vector store provider - #7090

Open
MitraShabani wants to merge 1 commit into
mem0ai:mainfrom
MitraShabani:main
Open

Add ClickHouse vector store provider#7090
MitraShabani wants to merge 1 commit into
mem0ai:mainfrom
MitraShabani:main

Conversation

@MitraShabani

Copy link
Copy Markdown

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

Linked Issue

Closes #6991

Description

Mem0 currently lacks support for ClickHouse as a vector store backend. This PR adds a ClickhouseDB provider implementing the full VectorStoreBase interface (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 via ALTER TABLE ... DELETE followed by insert, since ClickHouse's MergeTree engine has no native in-place update.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (no functional changes)
  • Documentation update

AI Assistance

  • No AI assistance
  • AI-assisted (autocomplete, or I asked a model questions while writing this)
  • AI-generated (an agent wrote most or all of this diff)

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.

  • I can explain every line of this diff and how it interacts with the rest of the codebase, without asking an AI tool.

Breaking Changes

N/A — this adds a new optional provider and does not change any existing behavior or interfaces.

Test Coverage

  • I added/updated unit tests
  • I added/updated integration tests
  • I tested manually (describe below)
  • No tests needed (explain why)

Added tests/vector_stores/test_clickhouse.py with 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 in test_pgvector.py.

Also manually verified end-to-end through mem0's public API (Memory.from_config(...) with provider: "clickhouse"), using real OpenAI embeddings for both add() and search() — not just the isolated ClickhouseDB class.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation if needed

@CLAassistant

CLAassistant commented Aug 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added documentation Improvements or additions to documentation sdk-python Python SDK specific vector-store Vector store backends (Qdrant, PGVector, Redis, etc.) labels Aug 23, 2026
@github-actions

Copy link
Copy Markdown

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 (.github/VOUCHED.td). Nothing is blocked and there is nothing you need to do.

A maintainer can vouch for you by commenting !vouch @MitraShabani on any issue.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation sdk-python Python SDK specific vector-store Vector store backends (Qdrant, PGVector, Redis, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a new ClickhouseDB vector store provider to the mem0/vector_stores/ directory.

2 participants