Skip to content

fix: enable branch creation on tables that uses lance-namespace#7403

Closed
dantasse wants to merge 1 commit into
lance-format:mainfrom
dantasse:dantasse/branches_on_external_manifest
Closed

fix: enable branch creation on tables that uses lance-namespace#7403
dantasse wants to merge 1 commit into
lance-format:mainfrom
dantasse:dantasse/branches_on_external_manifest

Conversation

@dantasse

@dantasse dantasse commented Jun 22, 2026

Copy link
Copy Markdown

Creating a branch fails on tables that use lance-namespace. On a lance-namespace table, this happens in order:

  1. write the manifest to a staging path under /tree//_versions/…manifest-
  2. call the namespace's create_table_version to record that version, reading _refs/branches/.json to find the location of the branch
  3. Write _refs/branches/.json
  4. So step 2 fails because .json isn't written yet. (the commit handler mislabels this as "dataset already exists"). So this PR adds resolve_branch_location_unchecked, which just computes the main branch's path and adds tree/<branch> which is the right location.

    (On unmanaged tables, step 2 doesn't happen, so there's no problem.)

    Edit: dir::tests::test_branch_ops_reject_zombie_branch fails; this isn't ready yet

@github-actions github-actions Bot added A-namespace Namespace impls bug Something isn't working labels Jun 22, 2026
@dantasse
dantasse marked this pull request as draft June 22, 2026 22:20
@dantasse dantasse closed this Jun 23, 2026
@dantasse
dantasse deleted the dantasse/branches_on_external_manifest branch June 23, 2026 15:02
jackye1995 pushed a commit that referenced this pull request Jun 23, 2026
This PR picks up on the work in #7403 by @dantasse.


`create_branch` on managed tables calls `create_table_version` before
`_refs/branches/<branch>.json` exists, and `resolve_branch_location`
requires that ref. Bootstrap commit fails.

`create_table_version` now goes through `resolve_branch_for_commit`
instead check the ref first, and if it's missing only allow the commit
when the branch chain has no versions yet. Versions without a ref still
get rejected (zombie).

`create_branch("exp")` used to fail on the first commit because
`create_table_version` looked for `_refs/branches/exp.json` before phase
2 wrote it.

```
# branching isn't atomic so:
phase 1: manifest → create_table_version (ref doesn't exist yet ← was failing here)
phase 2: write _refs/branches/exp.json
```

### Testing
- Added `test_create_branch_on_managed_dataset_succeeds`. 
- Zombie case is already in `test_branch_ops_reject_zombie_branch`.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-namespace Namespace impls bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant