mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +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)
|
||||
|
||||
|
||||
def explain_query_plan(sql):
|
||||
def explain_query_plan(sql, db=db):
|
||||
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'") == []
|
||||
|
||||
|
||||
# @pytest.mark.skip(reason="TODO failing locally for some reason")
|
||||
def test_vec0_text_pk():
|
||||
db = connect(EXT_PATH)
|
||||
db.execute(
|
||||
|
|
@ -1497,6 +1498,13 @@ def test_vec0_text_pk():
|
|||
]
|
||||
|
||||
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(
|
||||
db,
|
||||
"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.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
|
||||
db.execute("BEGIN")
|
||||
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()
|
||||
assert chunk["chunk_id"] == 1
|
||||
assert chunk["validity"] == bytearray(int(1024 / 8))
|
||||
assert chunk["rowids"] == bytearray(int(1024 * 8))
|
||||
vchunk = db.execute("select * from vec_xyz_vector_chunks00").fetchone()
|
||||
assert vchunk["rowid"] == 1
|
||||
assert vchunk["vectors"] == bytearray(int(1024 * 4 * 2))
|
||||
# as of TODO, no initial row is inside the chunks table
|
||||
assert chunk is None
|
||||
# assert chunk["chunk_id"] == 1
|
||||
# assert chunk["validity"] == bytearray(int(1024 / 8))
|
||||
# assert chunk["rowids"] == bytearray(int(1024 * 8))
|
||||
# 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(
|
||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:knn:",
|
||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:3{___}___",
|
||||
explain_query_plan(
|
||||
"select * from vec_xyz where a match X'' and k = 10 order by distance"
|
||||
),
|
||||
)
|
||||
if SUPPORTS_VTAB_LIMIT:
|
||||
assert re.match(
|
||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:knn:",
|
||||
"SCAN (TABLE )?vec_xyz VIRTUAL TABLE INDEX 0:3{___}___",
|
||||
explain_query_plan(
|
||||
"select * from vec_xyz where a match X'' order by distance limit 10"
|
||||
),
|
||||
)
|
||||
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"),
|
||||
)
|
||||
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"),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue