interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / vec1 / test / vec1join.test

46 lines · 1421 bytes Raw Blame History
1# 2026-08-04
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12#
13
14source [file join [file dirname [info script]] vec1_common.tcl]
15set testprefix vec1join
16vec1_load db
17
18do_execsql_test 1.0 {
19 CREATE VIRTUAL TABLE v1 USING vec1(a);
20 INSERT INTO v1(rowid, a) VALUES(1, vec1_from_json('[1,0,0,0]'));
21 INSERT INTO v1(rowid, a) VALUES(2, vec1_from_json('[0,1,0,0]'));
22 INSERT INTO v1(rowid, a) VALUES(3, vec1_from_json('[0,0,1,0]'));
23 INSERT INTO v1(rowid, a) VALUES(4, vec1_from_json('[0,0,0,1]'));
24 INSERT INTO v1(rowid, a) VALUES(5, vec1_from_json('[1,1,0,0]'));
25 INSERT INTO v1(cmd, arg) VALUES('rebuild', '{index:"flat"}');
26 CREATE TABLE q(id INTEGER PRIMARY KEY, qv BLOB);
27 INSERT INTO q VALUES(1, vec1_from_json('[1,0,0,0]'));
28}
29
30# Q1: literal query vector
31do_execsql_test 1.1 {
32 SELECT rowid FROM v1(vec1_from_json('[1,0,0,0]'), '{K:2}');
33} {1 5}
34
35# Q2: vector from table q, via CROSS JOIN
36do_execsql_test 1.2 {
37 SELECT v.rowid FROM q CROSS JOIN v1(q.qv, '{K:2}') AS v;
38} {1 5}
39
40# Q3: vector from table q, via CROSS JOIN
41do_execsql_test 1.3 {
42 SELECT v.rowid FROM q, v1(q.qv, '{K:2}') AS v;
43} {1 5}
44
45finish_test
46