feat: add table branch support#3490
Conversation
|
@claude review once |
|
@claude review once |
|
@claude review once |
1 similar comment
|
@claude review once |
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
Docs PR opened: lancedb/docs#263 Added a Branches page under Table operations covering creating, listing, checking out, and deleting table branches across Python, TypeScript, and Rust. Once this PR is merged, we'll do a second pass to capture any additional changes and update the docs PR. |
|
@claude review once |
wjones127
left a comment
There was a problem hiding this comment.
The API looks really well designed. I like this.
There are a few behavior / testing issues I think we need to address before we merge this.
| #[tokio::test] | ||
| async fn test_as_branch_is_writable_and_tracked() { |
There was a problem hiding this comment.
issue(blocking): one test I would like to see is what happens to a branch handle if it's concurrently updated? Does the branch handle track new writes to the branch? Either way we go, I think the behavior should be asserted in a test.
There was a problem hiding this comment.
I've added a test here to document the desired behaviour. A branch handle will track new writes to its branch at its read_consistency_interval.
|
|
||
|
|
||
| def test_branches(tmp_path): | ||
| db = lancedb.connect(tmp_path) |
There was a problem hiding this comment.
issue(blocking): the default for read_consistency_interval is None, which actually makes this test less useful. I would recommend setting this to zero for these kinds of tests:
| db = lancedb.connect(tmp_path) | |
| db = lancedb.connect(tmp_path, read_consistency_interval=timedelta(0)) |
There was a problem hiding this comment.
good catch, changed to 0
5696df2 to
d6143c5
Compare
|
Docs PR opened: lancedb/docs#267 Added a Branches section to the versioning guide covering create, checkout, list, and delete across Python, TypeScript, and Rust. |
### Description Stacked on #3490. Adds an optional version to branch checkout across the Rust core and the Python and TypeScript SDKs, so you can open a specific version on a branch ("version V of branch B"), not just the branch's latest version Rust ```rust // Open version 3 of branch "exp" (a read-only view): check out from an // existing table, or open it directly from the connection. let exp_v3 = table.checkout_branch("exp", Some(3)).await?; let exp_v3 = db.open_table("items").branch("exp").version(3).execute().await?; // checkout_latest re-attaches to the branch's writable HEAD. exp_v3.checkout_latest().await?; // With no branch, a version opens main at that version. let main_v3 = db.open_table("items").version(3).execute().await?; ``` Python ```python # Open version 3 of branch "exp" (a read-only view): check out from an # existing table, or open it directly from the connection. branch_v3 = await table.branches.checkout("exp", version=3) branch_v3 = await db.open_table("items", branch="exp", version=3) # checkout_latest re-attaches to the branch's writable HEAD. await branch_v3.checkout_latest() # With no branch, a version opens main at that version. main_v3 = await db.open_table("items", version=3) ``` TypeScript ```typescript // Open version 3 of branch "exp" (a read-only view): check out from an // existing table, or open it directly from the connection. const branchV3 = await (await table.branches()).checkout("exp", 3); const opened = await db.openTable("items", undefined, { branch: "exp", version: 3 }); // checkoutLatest re-attaches to the branch's writable HEAD. await branchV3.checkoutLatest(); // With no branch, a version opens main at that version. const mainV3 = await db.openTable("items", undefined, { version: 3 }); ``` ### Testing - Added unit tests (Rust, Python sync + async, TypeScript): branch-scoped resolution at a version number shared with `main` and with another branch, read-only enforcement on a pinned handle, `checkout_latest` recovery to the branch's HEAD, fork-point reads, and the nonexistent-version/branch error paths. - Ran smoke tests against the Python and TypeScript SDKs on local machine.
Description
Adds first-class support for table branches across the Rust core and the Python and TypeScript SDKs.
Rust
Python
TypeScript
Testing
Next steps