feat: support for deletion (#219)

Also upgrades Arrow and Lance.
This commit is contained in:
Will Jones
2023-06-23 18:09:07 -07:00
committed by GitHub
parent 1a9a392e20
commit ad48242ffb
11 changed files with 200 additions and 134 deletions

View File

@@ -43,7 +43,7 @@ class LanceDBConnection:
LanceTable(my_table)
>>> db.create_table("another_table", data=[{"vector": [0.4, 0.4], "b": 6}])
LanceTable(another_table)
>>> db.table_names()
>>> sorted(db.table_names())
['another_table', 'my_table']
>>> len(db)
2

View File

@@ -292,6 +292,34 @@ class LanceTable:
lance.write_dataset(data, tbl._dataset_uri, mode=mode)
return tbl
def delete(self, where: str):
"""Delete rows from the table.
Parameters
----------
where: str
The SQL where clause to use when deleting rows.
Examples
--------
>>> import lancedb
>>> import pandas as pd
>>> data = pd.DataFrame({"x": [1, 2, 3], "vector": [[1, 2], [3, 4], [5, 6]]})
>>> db = lancedb.connect("./.lancedb")
>>> table = db.create_table("my_table", data)
>>> table.to_pandas()
x vector
0 1 [1.0, 2.0]
1 2 [3.0, 4.0]
2 3 [5.0, 6.0]
>>> table.delete("x = 2")
>>> table.to_pandas()
x vector
0 1 [1.0, 2.0]
1 3 [5.0, 6.0]
"""
self._dataset.delete(where)
def _sanitize_schema(data: pa.Table, schema: pa.Schema = None) -> pa.Table:
"""Ensure that the table has the expected schema.

View File

@@ -1,7 +1,7 @@
[project]
name = "lancedb"
version = "0.1.8"
dependencies = ["pylance>=0.4.20", "ratelimiter", "retry", "tqdm", "aiohttp", "pydantic", "attr"]
dependencies = ["pylance~=0.5.0", "ratelimiter", "retry", "tqdm", "aiohttp", "pydantic", "attr"]
description = "lancedb"
authors = [
{ name = "LanceDB Devs", email = "dev@lancedb.com" },
@@ -37,7 +37,7 @@ repository = "https://github.com/lancedb/lancedb"
[project.optional-dependencies]
tests = [
"pytest", "pytest-mock", "doctest", "pytest-asyncio"
"pytest", "pytest-mock", "pytest-asyncio"
]
dev = [
"ruff", "pre-commit", "black"