Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions examples/ideas-board/test_semantic_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

The native ``VECTOR`` type requires v25.2+; ``ensure_table()`` also issues
``CREATE VECTOR INDEX`` (v26.2+). Boots the image named by ``CRDB_VECTOR_IMAGE``
(default ``cockroachdb/cockroach:latest-v25.2``). Skips cleanly when Docker is
(default ``cockroachdb/cockroach:latest-v26.2``). Skips cleanly when Docker is
unavailable, and skips honestly (rather than faking a pass) if the chosen image
lacks VECTOR support. Mirrors the Java ``SemanticSearchIT``.
lacks VECTOR/vector-index support. Mirrors the Java ``SemanticSearchIT``.
"""

from __future__ import annotations
Expand All @@ -17,7 +17,7 @@

from cockroachdb.ai import Document

IMAGE = os.environ.get("CRDB_VECTOR_IMAGE", "cockroachdb/cockroach:latest-v25.2")
IMAGE = os.environ.get("CRDB_VECTOR_IMAGE", "cockroachdb/cockroach:latest-v26.2")

# Four deterministic 3-dim vectors pointing in distinct directions.
DOCS = {
Expand All @@ -44,8 +44,11 @@ def dsn() -> str:


def _skip_if_no_vector(exc: Exception) -> None:
if "vector" in str(exc).lower():
pytest.skip(f"VECTOR unsupported on {IMAGE}: {exc}")
msg = str(exc).lower()
# VECTOR type / CREATE VECTOR INDEX absent on this image surfaces as a
# message mentioning "vector", or a generic "unimplemented" feature error.
if "vector" in msg or "unimplemented" in msg:
pytest.skip(f"VECTOR/vector-index unsupported on {IMAGE}: {exc}")
raise exc


Expand Down
2 changes: 1 addition & 1 deletion packages/cockroachdb-ai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "cockroachdb-ai"
version = "0.1.1"
version = "0.1.2"
description = "CockroachDB AI — vector search, RAG pipelines, and embedding providers for pgvector"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
8 changes: 6 additions & 2 deletions packages/cockroachdb-ai/src/cockroachdb/ai/vector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,14 @@ def ensure_table(self) -> None:
the session-level ``vector_search_beam_size``.
"""
dimensions = self._config.embedding_dimensions
with psycopg.connect(self._conninfo) as conn:
# Enable vector index feature (required for CREATE VECTOR INDEX)

# SET CLUSTER SETTING cannot run inside a multi-statement transaction,
# so enable the vector-index feature on its own autocommit connection
# before the CREATE TABLE / CREATE VECTOR INDEX transaction below.
with psycopg.connect(self._conninfo, autocommit=True) as conn:
conn.execute("SET CLUSTER SETTING feature.vector_index.enabled = true")

with psycopg.connect(self._conninfo) as conn:
conn.execute(
f"""
CREATE TABLE IF NOT EXISTS {self._table} (
Expand Down
Loading