Skip to content

Commit

Permalink
fixed redundant queries in test
Browse files Browse the repository at this point in the history
  • Loading branch information
swetavooda committed Apr 9, 2024
1 parent d537532 commit ef00ddb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
23 changes: 10 additions & 13 deletions test/expected/pinecone_zero_vector_insert.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-- SETUP
-- suppress output
\o /dev/null
NOTICE: Mock table created
delete from pinecone_mock;
-- logging level
SET client_min_messages = 'notice';
Expand Down Expand Up @@ -36,6 +35,16 @@ VALUES ('https://api.pinecone.io/indexes', 'POST', $${
}
}
}$$);
-- mock describe index stats
INSERT INTO pinecone_mock (url_prefix, method, response)
VALUES ('https://fakehost/describe_index_stats', 'GET', '{"namespaces":{},"dimension":3,"indexFullness":0,"totalVectorCount":0}');
INSERT INTO t (id, val) VALUES (2, '[0,0,0]');
-- create index after insering 0 vector - Throws an error
CREATE INDEX i2 ON t USING pinecone (val) WITH (spec = '{"serverless":{"cloud":"aws","region":"us-west-2"}}');
ERROR: Invalid vector: zero vector
HINT: Pinecone insists that dense vectors cannot be zero in all dimensions. I don't know why they do this to you even when your metric isn't cosine.
-- Truncate the table to remove the values for creating an index successfully
TRUNCATE TABLE t;
-- create index
CREATE INDEX i2 ON t USING pinecone (val) WITH (spec = '{"serverless":{"cloud":"aws","region":"us-west-2"}}');
INSERT INTO pinecone_mock (url_prefix, method, response)
Expand All @@ -49,18 +58,6 @@ VALUES ('https://fakehost/vectors/upsert',
}',
'{"upsertedCount":1}'
);
INSERT INTO pinecone_mock (url_prefix, method, response)
VALUES ('https://fakehost/vectors/upsert',
'{ "vectors": [
{
"id": "000000000002",
"values": [0, 0, 0],
"metadata": {
}
}]
}',
'ERROR'
);
INSERT INTO t (id, val) VALUES (1, '[100,1,1]');
INSERT INTO t (id, val) VALUES (2, '[0,0,0]');
ERROR: Invalid vector: zero vector
Expand Down
3 changes: 0 additions & 3 deletions test/sql/pinecone_zero_vector_insert.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-- SETUP
-- suppress output
\o /dev/null
SELECT pinecone_create_mock_table();
delete from pinecone_mock;
-- logging level
SET client_min_messages = 'notice';
Expand All @@ -10,8 +9,6 @@ SET pinecone.vectors_per_request = 1;
SET pinecone.requests_per_batch = 1;
-- disable flat scan to force use of the index
SET enable_seqscan = off;
-- Testing database is responsible for initializing the mock table with
-- SELECT pinecone_create_mock_table();
-- CREATE TABLE
DROP TABLE IF EXISTS t;
CREATE TABLE t (id int, val vector(3));
Expand Down

0 comments on commit ef00ddb

Please sign in to comment.