@@ -275,6 +275,36 @@ do_execsql_test vector-all-params {
275
275
SELECT * FROM vector_top_k('t_all_params_idx', vector('[1,2]'), 2);
276
276
} {1 2}
277
277
278
+ do_execsql_test vector-partial {
279
+ CREATE TABLE t_partial( name TEXT, type INT, v FLOAT32(3));
280
+ INSERT INTO t_partial VALUES ( 'a', 0, vector('[1,2,3]') );
281
+ INSERT INTO t_partial VALUES ( 'b', 1, vector('[3,4,5]') );
282
+ INSERT INTO t_partial VALUES ( 'c', 2, vector('[4,5,6]') );
283
+ INSERT INTO t_partial VALUES ( 'd', 0, vector('[5,6,7]') );
284
+ INSERT INTO t_partial VALUES ( 'e', 1, vector('[6,7,8]') );
285
+ INSERT INTO t_partial VALUES ( 'f', 2, vector('[7,8,9]') );
286
+ CREATE INDEX t_partial_idx_0 ON t_partial( libsql_vector_idx(v) ) WHERE type = 0;
287
+ CREATE INDEX t_partial_idx_1 ON t_partial( libsql_vector_idx(v) ) WHERE type = 1;
288
+ CREATE INDEX t_partial_idx_not_0 ON t_partial( libsql_vector_idx(v) ) WHERE type != 0;
289
+ SELECT id FROM vector_top_k('t_partial_idx_0', vector('[1,2,3]'), 10);
290
+ SELECT id FROM vector_top_k('t_partial_idx_1', vector('[1,2,3]'), 10);
291
+ SELECT id FROM vector_top_k('t_partial_idx_not_0', vector('[1,2,3]'), 10);
292
+ INSERT INTO t_partial VALUES ( 'g', 0, vector('[8,9,10]') );
293
+ INSERT INTO t_partial VALUES ( 'h', 1, vector('[9,10,11]') );
294
+ INSERT INTO t_partial VALUES ( 'i', 2, vector('[10,11,12]') );
295
+ SELECT id FROM vector_top_k('t_partial_idx_0', vector('[1,2,3]'), 10);
296
+ SELECT id FROM vector_top_k('t_partial_idx_1', vector('[1,2,3]'), 10);
297
+ SELECT id FROM vector_top_k('t_partial_idx_not_0', vector('[1,2,3]'), 10);
298
+ } {
299
+ 1 4
300
+ 2 5
301
+ 2 3 5 6
302
+
303
+ 1 4 7
304
+ 2 5 8
305
+ 2 3 5 6 8 9
306
+ }
307
+
278
308
proc error_messages {sql} {
279
309
set ret ""
280
310
catch {
@@ -309,8 +339,6 @@ do_test vector-errors {
309
339
sqlite3_exec db { CREATE TABLE t_mixed_t( v FLOAT32(3)); }
310
340
sqlite3_exec db { INSERT INTO t_mixed_t VALUES('[1]'); }
311
341
lappend ret [error_messages {CREATE INDEX t_mixed_t_idx ON t_mixed_t( libsql_vector_idx(v) )}]
312
- sqlite3_exec db { CREATE TABLE t_partial( name TEXT, type INT, v FLOAT32(3)); }
313
- lappend ret [error_messages {CREATE INDEX t_partial_idx ON t_partial( libsql_vector_idx(v) ) WHERE type = 0}]
314
342
} [list {*}{
315
343
{no such table: main.t_no}
316
344
{no such column: v}
@@ -328,5 +356,4 @@ do_test vector-errors {
328
356
{vector index(insert): only f32 vectors are supported}
329
357
{vector index(search): dimensions are different: 2 != 4}
330
358
{vector index(insert): dimensions are different: 1 != 3}
331
- {vector index: where condition is forbidden}
332
359
}]
0 commit comments