mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-05-02 20:32:41 +02:00
PARTITION KEY support (#122)
* initial pass at PARTITION KEY support. * unit tests * gha this PR branch * fixup tests * doc internal * fix tests, KNN/rowids in * define SQLITE_INDEX_CONSTRAINT_OFFSET * whoops * update tests, syrupy, use uv * un ignore pyproject.toml * dot * tests/ * type error? * win: .exe, update error name * try fix macos python, paren around expr? * win bash? * dbg :( * explicit error * op * dbg win * win ./tests/.venv/Scripts/python.exe * block UPDATEs on partition key values for now
This commit is contained in:
parent
ee3654701f
commit
6658624172
16 changed files with 1522 additions and 245 deletions
245
tests/__snapshots__/test-partition-keys.ambr
Normal file
245
tests/__snapshots__/test-partition-keys.ambr
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
# serializer version: 1
|
||||
# name: test_constructor_limit[max 4 partition keys]
|
||||
dict({
|
||||
'error': 'OperationalError',
|
||||
'message': 'vec0 constructor error: More than 4 partition key columns were provided',
|
||||
})
|
||||
# ---
|
||||
# name: test_normal[1 row]
|
||||
dict({
|
||||
'v_chunks': OrderedDict({
|
||||
'sql': 'select * from v_chunks',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'chunk_id': 1,
|
||||
'size': 8,
|
||||
'sequence_id': None,
|
||||
'partition00': 100,
|
||||
'validity': b'\x01',
|
||||
'rowids': b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_rowids': OrderedDict({
|
||||
'sql': 'select * from v_rowids',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'id': None,
|
||||
'chunk_id': 1,
|
||||
'chunk_offset': 0,
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_vector_chunks00': OrderedDict({
|
||||
'sql': 'select * from v_vector_chunks00',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'vectors': b'\x11"3D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
# name: test_normal[2 rows, same parition]
|
||||
dict({
|
||||
'v_chunks': OrderedDict({
|
||||
'sql': 'select * from v_chunks',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'chunk_id': 1,
|
||||
'size': 8,
|
||||
'sequence_id': None,
|
||||
'partition00': 100,
|
||||
'validity': b'\x03',
|
||||
'rowids': b'\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_rowids': OrderedDict({
|
||||
'sql': 'select * from v_rowids',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'id': None,
|
||||
'chunk_id': 1,
|
||||
'chunk_offset': 0,
|
||||
}),
|
||||
OrderedDict({
|
||||
'rowid': 2,
|
||||
'id': None,
|
||||
'chunk_id': 1,
|
||||
'chunk_offset': 1,
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_vector_chunks00': OrderedDict({
|
||||
'sql': 'select * from v_vector_chunks00',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'vectors': b'\x11"3DDUfw\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
# name: test_normal[3 rows, 2 partitions]
|
||||
dict({
|
||||
'v_chunks': OrderedDict({
|
||||
'sql': 'select * from v_chunks',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'chunk_id': 1,
|
||||
'size': 8,
|
||||
'sequence_id': None,
|
||||
'partition00': 100,
|
||||
'validity': b'\x03',
|
||||
'rowids': b'\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
OrderedDict({
|
||||
'chunk_id': 2,
|
||||
'size': 8,
|
||||
'sequence_id': None,
|
||||
'partition00': 200,
|
||||
'validity': b'\x01',
|
||||
'rowids': b'\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_rowids': OrderedDict({
|
||||
'sql': 'select * from v_rowids',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'id': None,
|
||||
'chunk_id': 1,
|
||||
'chunk_offset': 0,
|
||||
}),
|
||||
OrderedDict({
|
||||
'rowid': 2,
|
||||
'id': None,
|
||||
'chunk_id': 1,
|
||||
'chunk_offset': 1,
|
||||
}),
|
||||
OrderedDict({
|
||||
'rowid': 3,
|
||||
'id': None,
|
||||
'chunk_id': 2,
|
||||
'chunk_offset': 0,
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_vector_chunks00': OrderedDict({
|
||||
'sql': 'select * from v_vector_chunks00',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'vectors': b'\x11"3DDUfw\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
OrderedDict({
|
||||
'rowid': 2,
|
||||
'vectors': b'\x88\x99\xaa\xbb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
# name: test_types[1. raises type error]
|
||||
dict({
|
||||
'error': 'OperationalError',
|
||||
'message': 'Parition key type mismatch: The partition key column p1 has type INTEGER, but TEXT was provided.',
|
||||
})
|
||||
# ---
|
||||
# name: test_types[2. empty DB]
|
||||
dict({
|
||||
'v_chunks': OrderedDict({
|
||||
'sql': 'select * from v_chunks',
|
||||
'rows': list([
|
||||
]),
|
||||
}),
|
||||
'v_rowids': OrderedDict({
|
||||
'sql': 'select * from v_rowids',
|
||||
'rows': list([
|
||||
]),
|
||||
}),
|
||||
'v_vector_chunks00': OrderedDict({
|
||||
'sql': 'select * from v_vector_chunks00',
|
||||
'rows': list([
|
||||
]),
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
# name: test_types[3. allow nulls]
|
||||
OrderedDict({
|
||||
'sql': 'insert into v(p1, a) values(?, ?)',
|
||||
'rows': list([
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
# name: test_types[4. show NULL partition key]
|
||||
dict({
|
||||
'v_chunks': OrderedDict({
|
||||
'sql': 'select * from v_chunks',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'chunk_id': 1,
|
||||
'size': 8,
|
||||
'sequence_id': None,
|
||||
'partition00': None,
|
||||
'validity': b'\x01',
|
||||
'rowids': b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_rowids': OrderedDict({
|
||||
'sql': 'select * from v_rowids',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'id': None,
|
||||
'chunk_id': 1,
|
||||
'chunk_offset': 0,
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'v_vector_chunks00': OrderedDict({
|
||||
'sql': 'select * from v_vector_chunks00',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'vectors': b'\x11"3D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
# name: test_updates[1. Initial dataset]
|
||||
OrderedDict({
|
||||
'sql': 'select * from v',
|
||||
'rows': list([
|
||||
OrderedDict({
|
||||
'rowid': 1,
|
||||
'p': 'a',
|
||||
'a': b'\x11\x11\x11\x11',
|
||||
}),
|
||||
OrderedDict({
|
||||
'rowid': 2,
|
||||
'p': 'a',
|
||||
'a': b'""""',
|
||||
}),
|
||||
OrderedDict({
|
||||
'rowid': 3,
|
||||
'p': 'a',
|
||||
'a': b'3333',
|
||||
}),
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
# name: test_updates[2. update #1]
|
||||
dict({
|
||||
'error': 'OperationalError',
|
||||
'message': 'UPDATE on partition key columns are not supported yet. ',
|
||||
})
|
||||
# ---
|
||||
Loading…
Add table
Add a link
Reference in a new issue