mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-19 12:38:38 +00:00
feat(python): expose AsyncTable.to_lance (#3730)
## Summary - expose the existing async Lance dataset conversion as `AsyncTable.to_lance` - preserve table version, branch, and refreshed storage options when opening the dataset - route internal async pandas/query paths through the public API - cover normal tables, checked-out versions, branches, and forwarded dataset options ## Testing - `cd python && uv run --no-sync pytest python/tests/test_table.py -q` - `cd python && uv run --no-sync pytest python/tests/test_query.py -q` - `cd python && uv run --no-sync pytest --doctest-modules python/lancedb/table.py -q` - `uv run --project python --no-sync ruff format --check python/python/lancedb/table.py python/python/lancedb/query.py python/python/tests/test_table.py` - `uv run --project python --no-sync ruff check .` Fixes #1387
This commit is contained in:
@@ -1257,6 +1257,53 @@ def test_branch_to_lance_targets_branch(tmp_path):
|
||||
assert table.to_lance().count_rows() == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_to_lance(tmp_path):
|
||||
pytest.importorskip("lance")
|
||||
db = await lancedb.connect_async(tmp_path)
|
||||
table = await db.create_table("t", [{"i": 1}])
|
||||
|
||||
dataset = await table.to_lance()
|
||||
|
||||
assert dataset.count_rows() == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_branch_to_lance_targets_branch(tmp_path):
|
||||
pytest.importorskip("lance")
|
||||
db = await lancedb.connect_async(tmp_path)
|
||||
table = await db.create_table("t", [{"i": 1}])
|
||||
branch = await table.branches.create("exp")
|
||||
await branch.add([{"i": 2}])
|
||||
|
||||
assert (await branch.to_lance()).count_rows() == 2
|
||||
assert (await table.to_lance()).count_rows() == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_to_lance_targets_checked_out_version(tmp_path):
|
||||
pytest.importorskip("lance")
|
||||
db = await lancedb.connect_async(tmp_path)
|
||||
table = await db.create_table("t", [{"i": 1}])
|
||||
version = await table.version()
|
||||
await table.add([{"i": 2}])
|
||||
checked_out = await db.open_table("t", version=version)
|
||||
|
||||
assert (await checked_out.to_lance()).count_rows() == 1
|
||||
assert (await table.to_lance()).count_rows() == 2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_to_lance_forwards_dataset_options(tmp_path):
|
||||
pytest.importorskip("lance")
|
||||
db = await lancedb.connect_async(tmp_path)
|
||||
table = await db.create_table("t", [{"i": 1}])
|
||||
|
||||
dataset = await table.to_lance(default_scan_options={"with_row_id": True})
|
||||
|
||||
assert "_rowid" in dataset.schema.names
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_branches(tmp_path):
|
||||
db = await lancedb.connect_async(tmp_path)
|
||||
|
||||
Reference in New Issue
Block a user