test: assert branch handle read-consistency behavior

This commit is contained in:
Brendan Clement
2026-06-03 13:02:27 -07:00
parent 09518a3c1b
commit 5696df2791
2 changed files with 86 additions and 1 deletions

View File

@@ -904,7 +904,7 @@ async def test_async_tags(mem_db_async: AsyncConnection):
def test_branches(tmp_path):
db = lancedb.connect(tmp_path)
db = lancedb.connect(tmp_path, read_consistency_interval=timedelta(0))
table = db.create_table(
"test",
data=[
@@ -942,6 +942,22 @@ def test_branches(tmp_path):
assert "exp" not in table.branches.list()
def test_branch_handle_tracks_concurrent_writes(tmp_path):
db = lancedb.connect(tmp_path, read_consistency_interval=timedelta(0))
table = db.create_table("t", [{"id": 1}])
# two independent handles on the same branch
writer = table.branches.create("exp")
reader = db.open_table("t", branch="exp")
assert reader.count_rows() == 1
# a concurrent write on the branch is visible to the other handle
writer.add([{"id": 2}])
assert reader.count_rows() == 2
# main is unaffected
assert table.count_rows() == 1
def test_branch_name_validation(tmp_path):
db = lancedb.connect(tmp_path)
table = db.create_table("t", [{"id": 1}])