fix: add dataset path hint and sync open_table location (#5128)

## Summary

- Expose `location=` on sync `LanceDBConnection.open_table()`, matching
the existing async entry point while leaving remote and namespace APIs
unchanged.
- When a `ListingDatabase` connection URI ends in `.lance`, append a
parent-directory and table-stem hint to the derived-URI `TableNotFound`
error. The error classification and source chain are preserved, and no
extra storage probes are made.

Context: OSS-2858 remains canceled. This is only the narrow embedded DX
follow-up; it does not add a top-level `lancedb.open_table(uri)` API.

## Verification

- Rust targeted listing tests for the `.lance` hint and the
explicit-location path.
- Python sync `open_table` tests for `location=` and the `.lance` hint.
- Pickle round-trip of a sync `location=` table after #5114.
- `cargo check --features remote --tests --examples`, `cargo fmt
--check`, Ruff format/check.
This commit is contained in:
Xuanwo
2026-11-20 22:08:29 +08:00
committed by GitHub
parent 9799686986
commit 85f966a9a9
5 changed files with 227 additions and 21 deletions
+29
View File
@@ -869,6 +869,35 @@ def test_open_table_sync(tmp_db: lancedb.DBConnection):
tmp_db.open_table("does_not_exist")
def test_open_table_sync_with_location(tmp_path):
db = lancedb.connect(tmp_path / "db")
db.create_table("test", data=[{"id": 0}])
dataset_path = tmp_path / "db" / "test.lance"
other_db = lancedb.connect(tmp_path / "other")
opened = other_db.open_table("test", location=str(dataset_path))
assert opened.name == "test"
assert opened.count_rows() == 1
def test_open_table_sync_lance_dataset_path_hint(tmp_path):
data_dir = tmp_path / "data"
lancedb.connect(data_dir).create_table("embeddings", data=[{"id": 0}])
dataset_db = lancedb.connect(data_dir / "embeddings.lance")
with pytest.raises(ValueError) as exc_info:
dataset_db.open_table("embeddings")
message = str(exc_info.value)
assert "Table 'embeddings' was not found" in message
assert "points to a Lance dataset rather than a database directory" in message
assert f"parent directory '{data_dir}'" in message
assert "open table 'embeddings' instead" in message
with pytest.raises(ValueError) as exc_info:
dataset_db.open_table("missing", location=str(tmp_path / "missing.lance"))
assert "points to a Lance dataset" not in str(exc_info.value)
@pytest.mark.asyncio
async def test_open_table(tmp_path):
from conftest import pandas_string_type