Repository navigation
feat(table): store explicit deletion file path - #10914
Conversation
|
Important Format specification voteThis 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
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 |
|
Note: probably will need to port over some of the changes in #10926 to get tests passing |
wjones127
left a comment
There was a problem hiding this comment.
Thank you for working on this. I have a few blocking comments we should discuss.
There was a problem hiding this comment.
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.
wjones127
left a comment
There was a problem hiding this comment.
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.
lance/rust/lance/src/dataset/deletions.rs
Lines 120 to 124 in d829354
…erialize Co-authored-by: Drew <[email protected]>
## 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]>
Right now deletion file paths have a reverse dependency on the format and are derived from committed state such as
fragment_id,read_version, andid. 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
pathfield onDeletionFile(protobuf tag 5) so writers can record an explicit_deletions/{uuid}.{ext}location that does not depend on the fragment ID.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 bybase_id, must be under_deletions/, and its extension must matchfile_type.cc: @wjones127