mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-05 19:32:56 +00:00
fix: fix columns type for pydantic 2.x (#1045)
This commit is contained in:
2
.github/workflows/run_tests/action.yml
vendored
2
.github/workflows/run_tests/action.yml
vendored
@@ -11,7 +11,7 @@ runs:
|
||||
- name: Install lancedb
|
||||
shell: bash
|
||||
run: |
|
||||
pip3 install $(ls target/wheels/lancedb-*.whl)[tests,dev,embeddings]
|
||||
pip3 install $(ls target/wheels/lancedb-*.whl)[tests,dev]
|
||||
- name: pytest
|
||||
shell: bash
|
||||
run: pytest -m "not slow" -x -v --durations=30 python/python/tests
|
||||
|
||||
@@ -336,10 +336,8 @@ class LanceQueryBuilder(ABC):
|
||||
LanceQueryBuilder
|
||||
The LanceQueryBuilder object.
|
||||
"""
|
||||
if isinstance(columns, list):
|
||||
if isinstance(columns, list) or isinstance(columns, dict):
|
||||
self._columns = columns
|
||||
elif isinstance(columns, dict):
|
||||
self._columns = list(columns.items())
|
||||
else:
|
||||
raise ValueError("columns must be a list or a dictionary")
|
||||
return self
|
||||
|
||||
@@ -94,6 +94,17 @@ def test_query_builder(table):
|
||||
assert all(np.array(rs[0]["vector"]) == [1, 2])
|
||||
|
||||
|
||||
def test_dynamic_projection(table):
|
||||
rs = (
|
||||
LanceVectorQueryBuilder(table, [0, 0], "vector")
|
||||
.limit(1)
|
||||
.select({"id": "id", "id2": "id * 2"})
|
||||
.to_list()
|
||||
)
|
||||
assert rs[0]["id"] == 1
|
||||
assert rs[0]["id2"] == 2
|
||||
|
||||
|
||||
def test_query_builder_with_filter(table):
|
||||
rs = LanceVectorQueryBuilder(table, [0, 0], "vector").where("id = 2").to_list()
|
||||
assert rs[0]["id"] == 2
|
||||
|
||||
Reference in New Issue
Block a user