mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +02:00
add failing test causes for non eq text knn
This commit is contained in:
parent
07793b3ecc
commit
31622209eb
3 changed files with 211 additions and 29 deletions
|
|
@ -6119,7 +6119,10 @@ int vec0_set_metadata_filter_bitmap(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VEC0_METADATA_COLUMN_KIND_TEXT: {
|
case VEC0_METADATA_COLUMN_KIND_TEXT: {
|
||||||
vec0_metadata_filter_text(p, value, buffer, size, op, b, metadata_idx, chunk_rowid);
|
rc = vec0_metadata_filter_text(p, value, buffer, size, op, b, metadata_idx, chunk_rowid);
|
||||||
|
if(rc != SQLITE_OK) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -617,30 +617,201 @@
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_long_text_knn[knn-eq-short]
|
# name: test_long_text_knn[eq-bbbb]
|
||||||
OrderedDict({
|
|
||||||
'sql': "select * from v where vector match X'11111111' and k = 5 and name = ?",
|
|
||||||
'rows': list([
|
|
||||||
OrderedDict({
|
|
||||||
'rowid': 1,
|
|
||||||
'vector': b'\x11\x11\x11\x11',
|
|
||||||
'name': 'aaaaaaaaaaaa',
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
})
|
|
||||||
# ---
|
|
||||||
# name: test_long_text_knn[knn-eq-true]
|
|
||||||
OrderedDict({
|
OrderedDict({
|
||||||
'sql': "select * from v where vector match X'11111111' and k = 5 and name = ?",
|
'sql': "select * from v where vector match X'11111111' and k = 5 and name = ?",
|
||||||
'rows': list([
|
'rows': list([
|
||||||
OrderedDict({
|
OrderedDict({
|
||||||
'rowid': 3,
|
'rowid': 3,
|
||||||
'vector': b'\x11\x11\x11\x11',
|
'vector': b'\x11\x11\x11\x11',
|
||||||
'name': 'aaaaaaaaaaaa_aaa',
|
'name': 'bbbb',
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_long_text_knn[eq-bbbbbbbbbbbb_aaa]
|
||||||
|
OrderedDict({
|
||||||
|
'sql': "select * from v where vector match X'11111111' and k = 5 and name = ?",
|
||||||
|
'rows': list([
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[eq-bbbbbbbbbbbb_bbb]
|
||||||
|
OrderedDict({
|
||||||
|
'sql': "select * from v where vector match X'11111111' and k = 5 and name = ?",
|
||||||
|
'rows': list([
|
||||||
|
OrderedDict({
|
||||||
|
'rowid': 4,
|
||||||
|
'vector': b'\x11\x11\x11\x11',
|
||||||
|
'name': 'bbbbbbbbbbbb_bbb',
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[eq-bbbbbbbbbbbb_ccc]
|
||||||
|
OrderedDict({
|
||||||
|
'sql': "select * from v where vector match X'11111111' and k = 5 and name = ?",
|
||||||
|
'rows': list([
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[eq-longlonglonglonglonglonglong]
|
||||||
|
OrderedDict({
|
||||||
|
'sql': "select * from v where vector match X'11111111' and k = 5 and name = ?",
|
||||||
|
'rows': list([
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ge-bbbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ge-bbbbbbbbbbbb_aaa]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ge-bbbbbbbbbbbb_bbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ge-bbbbbbbbbbbb_ccc]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ge-longlonglonglonglonglonglong]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[gt-bbbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[gt-bbbbbbbbbbbb_aaa]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[gt-bbbbbbbbbbbb_bbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[gt-bbbbbbbbbbbb_ccc]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[gt-longlonglonglonglonglonglong]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[le-bbbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[le-bbbbbbbbbbbb_aaa]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[le-bbbbbbbbbbbb_bbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[le-bbbbbbbbbbbb_ccc]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[le-longlonglonglonglonglonglong]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[lt-bbbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[lt-bbbbbbbbbbbb_aaa]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[lt-bbbbbbbbbbbb_bbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[lt-bbbbbbbbbbbb_ccc]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[lt-longlonglonglonglonglonglong]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'Could not filter metadata fields',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ne-bbbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'unrecognized token: "!"',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ne-bbbbbbbbbbbb_aaa]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'unrecognized token: "!"',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ne-bbbbbbbbbbbb_bbb]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'unrecognized token: "!"',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ne-bbbbbbbbbbbb_ccc]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'unrecognized token: "!"',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_long_text_knn[ne-longlonglonglonglonglonglong]
|
||||||
|
dict({
|
||||||
|
'error': 'OperationalError',
|
||||||
|
'message': 'unrecognized token: "!"',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_long_text_updates
|
# name: test_long_text_updates
|
||||||
dict({
|
dict({
|
||||||
'v_chunks': OrderedDict({
|
'v_chunks': OrderedDict({
|
||||||
|
|
|
||||||
|
|
@ -138,22 +138,30 @@ def test_long_text_knn(db, snapshot):
|
||||||
"create virtual table v using vec0(vector float[1], name text, chunk_size=8)"
|
"create virtual table v using vec0(vector float[1], name text, chunk_size=8)"
|
||||||
)
|
)
|
||||||
INSERT = "insert into v(vector, name) values (?, ?)"
|
INSERT = "insert into v(vector, name) values (?, ?)"
|
||||||
exec(db, INSERT, [b"\x11\x11\x11\x11", "aaaaaaaaaaaa"])
|
exec(db, INSERT, [b"\x11\x11\x11\x11", "aaaa"])
|
||||||
exec(db, INSERT, [b"\x11\x11\x11\x11", "bbbbbbbbbbbb"])
|
|
||||||
exec(db, INSERT, [b"\x11\x11\x11\x11", "aaaaaaaaaaaa_aaa"])
|
exec(db, INSERT, [b"\x11\x11\x11\x11", "aaaaaaaaaaaa_aaa"])
|
||||||
exec(db, INSERT, [b"\x11\x11\x11\x11", "aaaaaaaaaaaa_bbb"])
|
exec(db, INSERT, [b"\x11\x11\x11\x11", "bbbb"])
|
||||||
exec(db, INSERT, [b"\x11\x11\x11\x11", "aaaaaaaaaaaa_ccc"])
|
exec(db, INSERT, [b"\x11\x11\x11\x11", "bbbbbbbbbbbb_bbb"])
|
||||||
|
exec(db, INSERT, [b"\x11\x11\x11\x11", "cccc"])
|
||||||
|
exec(db, INSERT, [b"\x11\x11\x11\x11", "cccccccccccc_ccc"])
|
||||||
|
|
||||||
assert exec(
|
tests = [
|
||||||
db,
|
"bbbb",
|
||||||
"select * from v where vector match X'11111111' and k = 5 and name = ?",
|
"bbbbbbbbbbbb_bbb",
|
||||||
["aaaaaaaaaaaa"],
|
"bbbbbbbbbbbb_aaa",
|
||||||
) == snapshot(name="knn-eq-short")
|
"bbbbbbbbbbbb_ccc",
|
||||||
assert exec(
|
"longlonglonglonglonglonglong",
|
||||||
db,
|
]
|
||||||
"select * from v where vector match X'11111111' and k = 5 and name = ?",
|
ops = ["=", "!-", "<", "<=", ">", ">="]
|
||||||
["aaaaaaaaaaaa_aaa"],
|
op_names = ["eq", "ne", "lt", "le", "gt", "ge"]
|
||||||
) == snapshot(name="knn-eq-true")
|
|
||||||
|
for test in tests:
|
||||||
|
for op, op_name in zip(ops, op_names):
|
||||||
|
assert exec(
|
||||||
|
db,
|
||||||
|
f"select * from v where vector match X'11111111' and k = 5 and name {op} ?",
|
||||||
|
[test],
|
||||||
|
) == snapshot(name=f"{op_name}-{test}")
|
||||||
|
|
||||||
|
|
||||||
def test_types(db, snapshot):
|
def test_types(db, snapshot):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue