mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 16:56:27 +02:00
fixup tests
This commit is contained in:
parent
84d6a149c0
commit
c7bcf58575
1 changed files with 21 additions and 25 deletions
|
|
@ -81,7 +81,7 @@ def connect(ext, path=":memory:", extra_entrypoint=None):
|
||||||
db = connect(EXT_PATH)
|
db = connect(EXT_PATH)
|
||||||
|
|
||||||
|
|
||||||
def explain_query_plan(sql):
|
def explain_query_plan(sql, db=db):
|
||||||
return db.execute("explain query plan " + sql).fetchone()["detail"]
|
return db.execute("explain query plan " + sql).fetchone()["detail"]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1420,6 +1420,7 @@ def test_vec0_point():
|
||||||
assert execute_all(db, "select * from t2 where id = 'xxx'") == []
|
assert execute_all(db, "select * from t2 where id = 'xxx'") == []
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.mark.skip(reason="TODO failing locally for some reason")
|
||||||
def test_vec0_text_pk():
|
def test_vec0_text_pk():
|
||||||
db = connect(EXT_PATH)
|
db = connect(EXT_PATH)
|
||||||
db.execute(
|
db.execute(
|
||||||
|
|
@ -1497,6 +1498,13 @@ def test_vec0_text_pk():
|
||||||
]
|
]
|
||||||
|
|
||||||
if SUPPORTS_VTAB_IN:
|
if SUPPORTS_VTAB_IN:
|
||||||
|
assert re.match(
|
||||||
|
("SCAN (TABLE )?t VIRTUAL TABLE INDEX 0:3{___}___\[___"),
|
||||||
|
explain_query_plan(
|
||||||
|
"select t_id, distance from t where aaa match '' and k = 3 and t_id in ('t_2', 't_3')",
|
||||||
|
db=db,
|
||||||
|
),
|
||||||
|
)
|
||||||
assert execute_all(
|
assert execute_all(
|
||||||
db,
|
db,
|
||||||
"select t_id, distance from t where aaa match ? and k = 3 and t_id in ('t_2', 't_3')",
|
"select t_id, distance from t where aaa match ? and k = 3 and t_id in ('t_2', 't_3')",
|
||||||
|
|
@ -1939,20 +1947,6 @@ def test_vec0_create_errors():
|
||||||
db.execute("create virtual table t1 using vec0(a float[1])")
|
db.execute("create virtual table t1 using vec0(a float[1])")
|
||||||
db.set_authorizer(None)
|
db.set_authorizer(None)
|
||||||
|
|
||||||
db.set_authorizer(authorizer_deny_on(sqlite3.SQLITE_INSERT, "t1_chunks"))
|
|
||||||
with _raises(
|
|
||||||
"Could not create create an initial chunk",
|
|
||||||
):
|
|
||||||
db.execute("create virtual table t1 using vec0(a float[1])")
|
|
||||||
db.set_authorizer(None)
|
|
||||||
|
|
||||||
db.set_authorizer(authorizer_deny_on(sqlite3.SQLITE_INSERT, "t1_vector_chunks00"))
|
|
||||||
with _raises(
|
|
||||||
"Could not create create an initial chunk",
|
|
||||||
):
|
|
||||||
db.execute("create virtual table t1 using vec0(a float[1])")
|
|
||||||
db.set_authorizer(None)
|
|
||||||
|
|
||||||
# EVIDENCE-OF: V21406_05476 vec0 init raises error on 'latest chunk' init error
|
# EVIDENCE-OF: V21406_05476 vec0 init raises error on 'latest chunk' init error
|
||||||
db.execute("BEGIN")
|
db.execute("BEGIN")
|
||||||
db.set_authorizer(authorizer_deny_on(sqlite3.SQLITE_READ, "t1_chunks", ""))
|
db.set_authorizer(authorizer_deny_on(sqlite3.SQLITE_READ, "t1_chunks", ""))
|
||||||
|
|
@ -2231,32 +2225,34 @@ def test_smoke():
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
chunk = db.execute("select * from vec_xyz_chunks").fetchone()
|
chunk = db.execute("select * from vec_xyz_chunks").fetchone()
|
||||||
assert chunk["chunk_id"] == 1
|
# as of TODO, no initial row is inside the chunks table
|
||||||
assert chunk["validity"] == bytearray(int(1024 / 8))
|
assert chunk is None
|
||||||
assert chunk["rowids"] == bytearray(int(1024 * 8))
|
# assert chunk["chunk_id"] == 1
|
||||||
vchunk = db.execute("select * from vec_xyz_vector_chunks00").fetchone()
|
# assert chunk["validity"] == bytearray(int(1024 / 8))
|
||||||
assert vchunk["rowid"] == 1
|
# assert chunk["rowids"] == bytearray(int(1024 * 8))
|
||||||
assert vchunk["vectors"] == bytearray(int(1024 * 4 * 2))
|
# vchunk = db.execute("select * from vec_xyz_vector_chunks00").fetchone()
|
||||||
|
# assert vchunk["rowid"] == 1
|
||||||
|
# assert vchunk["vectors"] == bytearray(int(1024 * 4 * 2))
|
||||||
|
|
||||||
assert re.match(
|
assert re.match(
|
||||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:knn:",
|
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:3{___}___",
|
||||||
explain_query_plan(
|
explain_query_plan(
|
||||||
"select * from vec_xyz where a match X'' and k = 10 order by distance"
|
"select * from vec_xyz where a match X'' and k = 10 order by distance"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if SUPPORTS_VTAB_LIMIT:
|
if SUPPORTS_VTAB_LIMIT:
|
||||||
assert re.match(
|
assert re.match(
|
||||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:knn:",
|
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:3{___}___",
|
||||||
explain_query_plan(
|
explain_query_plan(
|
||||||
"select * from vec_xyz where a match X'' order by distance limit 10"
|
"select * from vec_xyz where a match X'' order by distance limit 10"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert re.match(
|
assert re.match(
|
||||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:fullscan",
|
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:1",
|
||||||
explain_query_plan("select * from vec_xyz"),
|
explain_query_plan("select * from vec_xyz"),
|
||||||
)
|
)
|
||||||
assert re.match(
|
assert re.match(
|
||||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 3:point",
|
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 3:2",
|
||||||
explain_query_plan("select * from vec_xyz where rowid = 4"),
|
explain_query_plan("select * from vec_xyz where rowid = 4"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue