Add detach/attach test

This commit is contained in:
Robert Schulze 2024-08-09 10:45:29 +00:00
parent 40bed3e20f
commit e7c2bf49c3
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,3 @@
5 [0,2] 0
6 [0,2.1] 0.09999990463256836
7 [0,2.2] 0.20000004768371582

View File

@ -0,0 +1,20 @@
-- Tags: no-fasttest, no-ordinary-database
-- Tests that vector similarity indexes can be detached/attached.
SET allow_experimental_usearch_index = 1;
DROP TABLE IF EXISTS tab;
CREATE TABLE tab(id Int32, vec Array(Float32), INDEX idx vec TYPE usearch()) ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8192;
INSERT INTO tab VALUES (0, [1.0, 0.0]), (1, [1.1, 0.0]), (2, [1.2, 0.0]), (3, [1.3, 0.0]), (4, [1.4, 0.0]), (5, [0.0, 2.0]), (6, [0.0, 2.1]), (7, [0.0, 2.2]), (8, [0.0, 2.3]), (9, [0.0, 2.4]);
DETACH TABLE tab SYNC;
ATTACH TABLE tab;
WITH [0.0, 2.0] AS reference_vec
SELECT id, vec, L2Distance(vec, reference_vec)
FROM tab
ORDER BY L2Distance(vec, reference_vec)
LIMIT 3;
DROP TABLE tab;