Skip to content

feat(table): store explicit deletion file path - #10914

Merged
wjones127 merged 5 commits into
lance-format:mainfrom
geruh:deletes
Nov 19, 2026
Merged

wjones127 merged 5 commits into
lance-format:mainfrom
geruh:deletes

Conversation

@geruh

@geruh geruh commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Right now deletion file paths have a reverse dependency on the format and are derived from committed state such as fragment_id, read_version, and id. Meaning that when writing deletion files lance has to know the final fragment ID before it can name the file. If a commit retries and gets assigned a different fragment ID, the derived path points to the wrong object in storage.

This PR adds an optional path field on DeletionFile (protobuf tag 5) so writers can record an explicit _deletions/{uuid}.{ext} location that does not depend on the fragment ID.

Derived path (couples file write to fragment ID allocation)
  Write file -> _deletions/0-1-100.bin (assumes fragment_id = 0)
  Commit     -> concurrent commit takes 0, fragment gets assigned 42
  Read       -> looks for _deletions/42-1-100.bin (missing or wrong file)

Explicit path (decouples file write from metadata)
  Write file -> _deletions/{uuid}.bin
  Commit     -> fragment gets assigned 42, DeletionFile.path stays unchanged
  Read       -> opens _deletions/{uuid}.bin

Explicit deletion paths are carried through the Rust, Python, and Java fragment metadata APIs. FLAG_DELETION_FILE_PATHS (bit 21) is required in the reader flags while a manifest contains explicit paths, and the writer flag stays set on later versions so cleanup preserves files referenced by older manifests. The path is relative to the dataset root selected by base_id, must be under _deletions/, and its extension must match file_type.

cc: @wjones127

@github-actions github-actions Bot added A-python Python bindings A-java Java bindings + JNI A-format On-disk format: protos and format spec docs format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). enhancement New feature or request labels Nov 10, 2026
@geruh
geruh marked this pull request as ready for review November 10, 2026 20:09

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Important

Format specification vote

This PR modifies the Lance format specification, so it requires 3 binding +1 votes from PMC members (excluding the proposer), at least one of them on the latest commit, and a minimum 72-hour voting period, weekends excluded, before it can merge. Vote by approving this PR (+1) or requesting changes (−1, a veto). See the voting process.

Approvals carry over across pushes, so a rebase or a typo fix does not send everyone back to re-vote. Whoever approves the latest commit is vouching that nothing substantive has changed since the earlier approvals; if something has, ask for fresh votes.

Status: ✅ Vote passed — 3 PMC approvals, voting period elapsed

Approvals @wjones127, @LuQQiu, @wkalt (3/3)
Latest commit approved by @wjones127
Vetoes none
Voting period elapsed — ended Fri 2026-11-13 20:09 UTC (12:09 PST)

Updated automatically by the format-spec vote gate, which re-checks every 15 minutes — just voted? Re-check now (press Run workflow; leave the input blank to re-check every open format PR). A PMC member may apply the format-waived label to waive the vote for a trivial edit (typo, wording, formatting).

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 10, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 10, 2026
@geruh

geruh commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Note: probably will need to port over some of the changes in #10926 to get tests passing

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 10, 2026

@wjones127 wjones127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this. I have a few blocking comments we should discuss.

Comment thread protos/fragment_metadata.proto Resolved
Comment thread docs/src/format/table/layout.md Resolved
Comment thread protos/fragment_metadata.proto Resolved
Comment thread docs/src/format/table/index.md Resolved
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 11, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 11, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 11, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 13, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 16, 2026
@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 17, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Gate recommendation: approve with a non-blocking risk.

The Python and Java round-trip findings remain fixed: both bindings preserve explicit deletion paths through committed metadata. The reader flag clears when no explicit paths remain, while the writer flag continues protecting retained versions.

Inline conversion still fails safely for explicit-path vectors. Keep them file-backed until #10925 clears path during conversion; manifest validation prevents publishing conflicting locations.

Please mark this PR with the breaking-change label: lance_table::format::DeletionFile adds a required path field, so Rust struct-literal callers must initialize it.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 17, 2026

@wjones127 wjones127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for carrying path through the bindings and tightening the flag rules. Everything from my last round is addressed. Approving, with one non-blocking issue on the reachable expect and a couple of questions inline.

suggestion: reminder for the #10925 follow-up: inline_fragment_deletions sets inline but leaves path, so inline_deletions() fails once any fragment has an explicit path. It needs deletion_file.path = None; plus a test.

deletion_file.file_type = DeletionFileType::Bitmap;
deletion_file.num_deleted_rows = Some(bitmap.len() as usize);
deletion_file.base_id = None;
deletion_file.inline = Some(encoded.into());
Ok(Some(fragment))

Comment thread rust/lance-table/src/io/deletion.rs Resolved
Comment thread rust/lance-table/src/feature_flags.rs Resolved
Comment thread rust/lance-table/src/feature_flags.rs Resolved
Comment thread rust/lance/src/session/caches.rs Resolved
@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 17, 2026
@wjones127
wjones127 merged commit 6db80a6 into lance-format:main Nov 19, 2026
45 checks passed
Xuanwo pushed a commit that referenced this pull request Nov 20, 2026
## Why

This PR is the format vote for the composite key track in #10250. It
specifies how a BTree index stores encoded keys, for two or more columns
or for one column with an explicit direction and null placement, so that
later PRs can build the codec, training, and search against a voted
contract.

## What changed

- `BTreeIndexDetails` gains an optional `key_layout`. It sets the key
encoding and the key ordering, each a `oneof` with one message per kind,
and gives each key its direction and null placement. The `arrow_row`
message carries its version.
- Index version 2 is a superset of version 1. A version 2 segment
without `key_layout` has the version 1 layout, and a reader picks the
page layout from whether `key_layout` is present, not from the number of
fields.
- The BTree spec gains an experimental Key Layout section. It covers
one-key and composite layouts, the Binary page layout, the `arrow_row`
version 1 bytes with 52 examples from the Arrow ordering fixtures, the
`lexicographic` ordering, the reader rules, and the writer rules. A
short compatibility section gives the reason for each fence: the index
version fences released readers, and the flag fences the v12.0.0 and
v13.0.0 writers that would otherwise extend `fragment_bitmap`.
- The writer rules state as musts when a writer sets bit 22, that it
drops a segment with a `key_layout` from a manifest without the bit, and
how it maintains a segment it cannot use. Compaction may rewrite the
fragments such a segment covers. The same commit removes them from its
`fragment_bitmap`, as an update does, also when compaction defers the
remap to a fragment reuse index, and readers scan them. By default, a
writer builds a single-column index without a `key_layout`. One-key
layouts stay allowed.
- Writer feature flag bit 22, `FLAG_BTREE_KEY_LAYOUT`, is reserved and
unsupported, and `lance-tools` names it `btree_key_layout`. Its doc
comment says what the bit means and links to the writer rules. Bits 19,
20, and 21 went to `FLAG_INLINE_DELETIONS`,
`FLAG_LOCAL_FRAGMENT_ALIASES` (#10780), and `FLAG_DELETION_FILE_PATHS`
(#10914) on `main`. The bit 22 fence re-check passed 173 checks: 104
table and chain checks matched the expected outcomes, and all 69 rows
shared with the bit 20 runs matched cell for cell. It gives the table
below.
- `main` checks in generated protobuf code, so
`rust/lance-index/src/pb/lance.table.rs` is regenerated for
`key_layout`.
- Encoding Stability now pins `arrow_row` version 1 to `arrow-row`
59.3.3, the version `main` builds with, and the `arrow_ordering.rs`
fixtures pass on it.

## Scope

- Spec, proto, the regenerated protobuf code, and the reserved flag with
its `lance-tools` name. No table writer emits a `key_layout` or derives
bit 22 yet, and no BTree query path interprets `key_layout`. Generated
protobuf code can decode the field, the feature-flag gate rejects bit 22
as unsupported, and `lance-tools` renders its name.
- Bit 22 covers only segments with a `key_layout`. #10352 added
`FLAG_ROW_ADDR_INDICES` at bit 18 for stable row ID tables with a BTree
at index version 1 or above, but `FLAG_ROW_ADDR_INDICES` cannot replace
`FLAG_BTREE_KEY_LAYOUT`: writers that support `FLAG_ROW_ADDR_INDICES`
without `key_layout` support (such as 15.0.0b7) recompute bit 18 from
`index_version >= 1` on restore, clone, and commits without checking the
source manifest's flags or dropping a damaged `key_layout` segment after
a 10.0.0 or 11.0.0 restore clears bit 18 and a 12.0.0 or 13.0.0 update
extends `fragment_bitmap`. Keeping `FLAG_BTREE_KEY_LAYOUT` as an
independent bit that pre-`key_layout` writers cannot set ensures a
damaged segment never becomes usable again.
- Covering columns on an index with a `key_layout` are left to a later
vote.

## Blast Radius

Every BTree written today has empty details, so it decodes as before. No
writer sets bit 22 yet. Index version 2 is free, because #10150 kept
stable row ID BTrees on version 1 and #10152 does not change the index
version.

## Verification

- A script implements `arrow_row` version 1 from the spec text alone. It
reproduces all 113 fixtures in `rust/lance/tests/arrow_ordering.rs` and
all 52 examples on the page. On 3,000 random tuples, byte order equals
the `lexicographic` order. Three planted errors each fail it.
- Fence probe. The head Rust API writes a table with a composite index
at index version 2 and sets `FLAG_BTREE_KEY_LAYOUT`, once with stable
row IDs and once without. Each pylance release runs each write first on
its own copy, then queries `a = 1` and `b = 1`.
- A one-key `key_layout` meets the same fences, from reading 10.0.0
through 14.0.0. Every release drops a BTree segment above its maximum
index version from the index list that reads and query planning use,
before any code counts `fields`. The commits of 10.0.0 and 11.0.0 also
use that filtered list, which is why they drop the index. The commits of
12.0.0 through 14.0.0 keep the segment, and an update counts its
`fields`, but `FLAG_BTREE_KEY_LAYOUT` refuses those commits. Once a
10.0.0 or 11.0.0 restore clears the bit, the reader rule makes the
segment unusable whatever its key count, even if a writer that supports
`FLAG_ROW_ADDR_INDICES` (`2^18`) later sets bit 18 again.
- `cargo run --locked --manifest-path protos/codegen/Cargo.toml --
--check`, `cargo test -p lance-table --lib feature_flags`, `cargo test
-p lance-tools format_feature_flags`, `cargo test -p lance --test
arrow_ordering`, `cargo fmt --all -- --check`, workspace clippy,
`ci/check_proto_comments.py`, `ci/check_module_size.py`, and `make
build` in `docs/` pass, and every link and anchor on the changed pages
resolves.

The index version fences readers. In 10.0.0 through 14.0.0, `a = 1` and
`b = 1` return the same rows as a full scan after every write, and no
plan uses the composite index. Bit 22 fences writers from 12.0.0 on.
"Stable" and "plain" name the table kind where the two differ.

| Release | Insert | Update, delete, create index, add column | Restore,
shallow clone, create branch | `optimize_indices()` | `compact_files()`
|
| --- | --- | --- | --- | --- | --- |
| 14.0.0 | refused | refused | refused | refused | stable refused, plain
commits nothing |
| 13.0.0, 12.0.0 | refused | refused | refused | stable commits nothing,
plain refused | stable refused, plain commits nothing |
| 11.0.0, 10.0.0 | refused | drops the index, clears bit 22 | keeps the
index, clears bit 22 | stable commits nothing, plain drops the index and
clears bit 22 | drops the index, clears bit 22 |
| head, stable only | refused | refused | refused | refused | refused |

After an 11.0.0 restore, shallow clone, or branch clears bit 22, a
13.0.0 update moves the composite index's `fragment_bitmap` from `[0, 1,
2, 3]` to `[0, 1, 2, 3, 5]`, and a 15.0.0b7 restore sets bit 18
(`FLAG_ROW_ADDR_INDICES`) again while leaving bit 22
(`FLAG_BTREE_KEY_LAYOUT`) clear. That result is why an index with a
`key_layout` from a manifest without `FLAG_BTREE_KEY_LAYOUT` is
unusable.

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Will Jones <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-format On-disk format: protos and format spec docs A-java Java bindings + JNI A-python Python bindings enhancement New feature or request format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants