mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-23 13:29:57 +00:00
Compare commits
4 Commits
python-v0.
...
python-v0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3059dc689 | ||
|
|
a9caa5f2d4 | ||
|
|
8411c36b96 | ||
|
|
7773bda7ee |
@@ -5,10 +5,10 @@ exclude = ["python"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
lance = { "version" = "=0.9.1", "features" = ["dynamodb"] }
|
lance = { "version" = "=0.9.2", "features" = ["dynamodb"] }
|
||||||
lance-index = { "version" = "=0.9.1" }
|
lance-index = { "version" = "=0.9.2" }
|
||||||
lance-linalg = { "version" = "=0.9.1" }
|
lance-linalg = { "version" = "=0.9.2" }
|
||||||
lance-testing = { "version" = "=0.9.1" }
|
lance-testing = { "version" = "=0.9.2" }
|
||||||
# Note that this one does not include pyarrow
|
# Note that this one does not include pyarrow
|
||||||
arrow = { version = "49.0.0", optional = false }
|
arrow = { version = "49.0.0", optional = false }
|
||||||
arrow-array = "49.0"
|
arrow-array = "49.0"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ LanceDB integrates with Pydantic for schema inference, data ingestion, and query
|
|||||||
|
|
||||||
LanceDB supports to create Apache Arrow Schema from a
|
LanceDB supports to create Apache Arrow Schema from a
|
||||||
[Pydantic BaseModel](https://docs.pydantic.dev/latest/api/main/#pydantic.main.BaseModel)
|
[Pydantic BaseModel](https://docs.pydantic.dev/latest/api/main/#pydantic.main.BaseModel)
|
||||||
via [pydantic_to_schema()](python.md##lancedb.pydantic.pydantic_to_schema) method.
|
via [pydantic_to_schema()](python.md#lancedb.pydantic.pydantic_to_schema) method.
|
||||||
|
|
||||||
::: lancedb.pydantic.pydantic_to_schema
|
::: lancedb.pydantic.pydantic_to_schema
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.4.2
|
current_version = 0.4.3
|
||||||
commit = True
|
commit = True
|
||||||
message = [python] Bump version: {current_version} → {new_version}
|
message = [python] Bump version: {current_version} → {new_version}
|
||||||
tag = True
|
tag = True
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Query(pydantic.BaseModel):
|
|||||||
vector_column: str = VECTOR_COLUMN_NAME
|
vector_column: str = VECTOR_COLUMN_NAME
|
||||||
|
|
||||||
# vector to search for
|
# vector to search for
|
||||||
vector: List[float]
|
vector: Union[List[float], List[List[float]]]
|
||||||
|
|
||||||
# sql filter to refine the query with
|
# sql filter to refine the query with
|
||||||
filter: Optional[str] = None
|
filter: Optional[str] = None
|
||||||
@@ -421,6 +421,8 @@ class LanceVectorQueryBuilder(LanceQueryBuilder):
|
|||||||
vector and the returned vectors.
|
vector and the returned vectors.
|
||||||
"""
|
"""
|
||||||
vector = self._query if isinstance(self._query, list) else self._query.tolist()
|
vector = self._query if isinstance(self._query, list) else self._query.tolist()
|
||||||
|
if isinstance(vector[0], np.ndarray):
|
||||||
|
vector = [v.tolist() for v in vector]
|
||||||
query = Query(
|
query = Query(
|
||||||
vector=vector,
|
vector=vector,
|
||||||
filter=self._where,
|
filter=self._where,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import uuid
|
import uuid
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from typing import Dict, Optional, Union
|
from typing import Dict, Optional, Union
|
||||||
@@ -227,8 +228,24 @@ class RemoteTable(Table):
|
|||||||
return LanceVectorQueryBuilder(self, query, vector_column_name)
|
return LanceVectorQueryBuilder(self, query, vector_column_name)
|
||||||
|
|
||||||
def _execute_query(self, query: Query) -> pa.Table:
|
def _execute_query(self, query: Query) -> pa.Table:
|
||||||
result = self._conn._client.query(self._name, query)
|
if (
|
||||||
return self._conn._loop.run_until_complete(result).to_arrow()
|
query.vector is not None
|
||||||
|
and len(query.vector) > 0
|
||||||
|
and not isinstance(query.vector[0], float)
|
||||||
|
):
|
||||||
|
futures = []
|
||||||
|
for v in query.vector:
|
||||||
|
v = list(v)
|
||||||
|
q = query.copy()
|
||||||
|
q.vector = v
|
||||||
|
futures.append(self._conn._client.query(self._name, q))
|
||||||
|
result = self._conn._loop.run_until_complete(asyncio.gather(*futures))
|
||||||
|
return pa.concat_tables(
|
||||||
|
[add_index(r.to_arrow(), i) for i, r in enumerate(result)]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
result = self._conn._client.query(self._name, query)
|
||||||
|
return self._conn._loop.run_until_complete(result).to_arrow()
|
||||||
|
|
||||||
def delete(self, predicate: str):
|
def delete(self, predicate: str):
|
||||||
"""Delete rows from the table.
|
"""Delete rows from the table.
|
||||||
@@ -342,3 +359,11 @@ class RemoteTable(Table):
|
|||||||
self._conn._loop.run_until_complete(
|
self._conn._loop.run_until_complete(
|
||||||
self._conn._client.post(f"/v1/table/{self._name}/update/", data=payload)
|
self._conn._client.post(f"/v1/table/{self._name}/update/", data=payload)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_index(tbl: pa.Table, i: int) -> pa.Table:
|
||||||
|
return tbl.add_column(
|
||||||
|
0,
|
||||||
|
pa.field("query_index", pa.uint32()),
|
||||||
|
pa.array([i] * len(tbl), pa.uint32()),
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "lancedb"
|
name = "lancedb"
|
||||||
version = "0.4.2"
|
version = "0.4.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deprecation",
|
"deprecation",
|
||||||
"pylance==0.9.1",
|
"pylance==0.9.2",
|
||||||
"ratelimiter~=1.0",
|
"ratelimiter~=1.0",
|
||||||
"retry>=0.9.2",
|
"retry>=0.9.2",
|
||||||
"tqdm>=4.27.0",
|
"tqdm>=4.27.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user