diff --git a/cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py b/cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py index d883a29e7..96f026b4f 100644 --- a/cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +++ b/cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py @@ -112,10 +112,18 @@ class LanceDBAdapter(VectorDBInterface): for (data_point_index, data_point) in enumerate(data_points) ] - await collection.merge_insert("id") \ - .when_matched_update_all() \ - .when_not_matched_insert_all() \ - .execute(lance_data_points) + # TODO: This enables us to work with pydantic version but shouldn't + # stay like this, existing rows should be updated + + await collection.delete("id IS NOT NULL") + + original_size = await collection.count_rows() + await collection.add(lance_data_points) + new_size = await collection.count_rows() + + if new_size <= original_size: + raise ValueError( + "LanceDB create_datapoints error: data points did not get added.") async def retrieve(self, collection_name: str, data_point_ids: list[str]):