Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Raise if named vector not found in local mode while upsert #813

Merged
merged 3 commits into from
Oct 18, 2024
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
2 changes: 2 additions & 0 deletions qdrant_client/local/local_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,8 @@ def _upsert_point(self, point: models.PointStruct) -> None:
"Wrong input: Unnamed vectors are not allowed when a collection has named vectors or multivectors: "
f"{vector_names}, {multivector_names}"
)
if not self.vectors and not self.multivectors:
raise ValueError(f"Wrong input: Not existing vector name error")

if point.id in self.ids:
self._update_point(point)
Expand Down
21 changes: 21 additions & 0 deletions tests/congruence_tests/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,24 @@ def test_upload_wrong_vectors():
wrong_vectors_collection,
points=[models.PointStruct(id=1, vector=unnamed_vector)],
)


def test_upsert_without_vector_name():
local_client = init_local()
remote_client = init_remote()

local_client.create_collection(collection_name=COLLECTION_NAME, vectors_config={})
if remote_client.collection_exists(collection_name=COLLECTION_NAME):
remote_client.delete_collection(collection_name=COLLECTION_NAME)
remote_client.create_collection(collection_name=COLLECTION_NAME, vectors_config={})

with pytest.raises(ValueError, match="Not existing vector name error"):
local_client.upsert(
COLLECTION_NAME, points=[models.PointStruct(id=1, vector=[0.1, 0.2, 0.3])]
)
with pytest.raises(
qdrant_client.http.exceptions.UnexpectedResponse, match="Not existing vector name error"
):
remote_client.upsert(
COLLECTION_NAME, points=[models.PointStruct(id=1, vector=[0.1, 0.2, 0.3])]
)
Loading