Repository navigation
feat(format): add data_change to DataReplacement - #9705
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: ❌ Blocked — 1 of 3 required approvals
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 |
|
@wjones127 @Xuanwo this is the format part of #9604, split out as voting.md asks. It's ready for review and votes. |
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The additive field and absent-as-true contract preserve existing transactions. This format-only change can precede #9604, which supplies the runtime behavior; current writers keep the existing encoding.
Please mark this PR with the breaking-change label.
|
@wjones127 Do we need to wait for more approvals? |
Yes, I'll ask for more votes. |
Thanks |
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's #9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eaning Main's #9705 gave DataReplacement.data_change = false effects beyond change data capture: index coverage is kept, overlays are left alone, and no row's last-updated-at version moves. A V2 re-encode is TombstoneFieldData followed by AddDataFile, so give a false tombstone the same meaning, and state what makes the flag valid: every tombstoned field is re-bound by an AddDataFile that is also false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A TombstoneFieldData with data_change false now means what main's #9705 gives DataReplacement.data_change false: the values only move, so the fields' overlays keep shadowing the base and their indices keep covering the fragment. Its footprint no longer counts as writing values, so a concurrent nullability tightening is not invalidated by it. Apply rejects a false tombstone that the operation does not re-bind with an AddDataFile, and a re-bind whose data_change disagrees with its tombstone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A TombstoneFieldData with data_change false now means what main's #9705 gives DataReplacement.data_change false: the values only move, so the fields' overlays keep shadowing the base and their indices keep covering the fragment. Its footprint no longer counts as writing values, so a concurrent nullability tightening is not invalidated by it. Apply rejects a false tombstone that the operation does not re-bind with an AddDataFile, and a re-bind whose data_change disagrees with its tombstone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's #9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A TombstoneFieldData with data_change false now means what main's #9705 gives DataReplacement.data_change false: the values only move, so the fields' overlays keep shadowing the base and their indices keep covering the fragment. Its footprint no longer counts as writing values, so a concurrent nullability tightening is not invalidated by it. Apply rejects a false tombstone that the operation does not re-bind with an AddDataFile, and a re-bind whose data_change disagrees with its tombstone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's #9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A TombstoneFieldData with data_change false now means what main's #9705 gives DataReplacement.data_change false: the values only move, so the fields' overlays keep shadowing the base and their indices keep covering the fragment. Its footprint no longer counts as writing values, so a concurrent nullability tightening is not invalidated by it. Apply rejects a false tombstone that the operation does not re-bind with an AddDataFile, and a re-bind whose data_change disagrees with its tombstone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's #9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's #9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A TombstoneFieldData with data_change false now means what main's #9705 gives DataReplacement.data_change false: the values only move, so the fields' overlays keep shadowing the base and their indices keep covering the fragment. Its footprint no longer counts as writing values, so a concurrent nullability tightening is not invalidated by it. Apply rejects a false tombstone that the operation does not re-bind with an AddDataFile, and a re-bind whose data_change disagrees with its tombstone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's #9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eaning Main's lance-format#9705 gave DataReplacement.data_change = false effects beyond change data capture: index coverage is kept, overlays are left alone, and no row's last-updated-at version moves. A V2 re-encode is TombstoneFieldData followed by AddDataFile, so give a false tombstone the same meaning, and state what makes the flag valid: every tombstoned field is re-bound by an AddDataFile that is also false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A TombstoneFieldData with data_change false now means what main's lance-format#9705 gives DataReplacement.data_change false: the values only move, so the fields' overlays keep shadowing the base and their indices keep covering the fragment. Its footprint no longer counts as writing values, so a concurrent nullability tightening is not invalidated by it. Apply rejects a false tombstone that the operation does not re-bind with an AddDataFile, and a re-bind whose data_change disagrees with its tombstone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's lance-format#9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A TombstoneFieldData with data_change false now means what main's #9705 gives DataReplacement.data_change false: the values only move, so the fields' overlays keep shadowing the base and their indices keep covering the fragment. Its footprint no longer counts as writing values, so a concurrent nullability tightening is not invalidated by it. Apply rejects a false tombstone that the operation does not re-bind with an AddDataFile, and a re-bind whose data_change disagrees with its tombstone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A re-encode with data_change false moves a field's values without changing any, so an index segment built over them still describes them. Claim the moved data as a new Mode::Moves, which collides with writes the way a write does but not with a segment's requirement, matching main's #9705: a concurrent index build no longer conflicts with a DataReplacement whose data_change is false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#9604) Builds on #9705, which added `data_change` to the format. ## What's wrong today? Each `add_columns` backfill gives every fragment another data file, which slows scans and random reads. `compact_files` never merges them: it picks fragments with many deletions or overlays, or few rows (#4286, #3995). ## What does this change? `compact_files` can also plan a task that repacks one fragment's columns into fewer data files. Rows don't move, so fragment ids, deletions, overlays and index coverage stay. A fragment no rewrite takes is repacked when it holds its columns in more than `max_data_files_per_fragment` files (off by default; also table config). This is the only trigger; #11035 tracks dead slots. A repack merges only files it can empty, at least two at a time. Files with a blob column, part of a column or spilled row lineage stay, and V1 fragments are skipped. `scope` limits a run to rewrites or repacks, and repacks are budgeted after rewrites. `ForceBinaryCopy` plans no repacks, and a repack-only run with no limit or under `ForceBinaryCopy` is refused. ## How does a repack commit? `commit_compaction` commits rewrites as one `Rewrite`, then repacks as one `DataReplacement { data_change: false }`: index coverage of the moved fields stays, overlays keep shadowing, and row versions don't move. A concurrent change to a moved column, a rewrite or delete of the fragment, or an `add_columns` makes it retry. The planner's fragment reuse index checks apply only to runs that rewrite. `DataReplacement` now takes several groups per fragment, and what it does to a fragment's files is one pure function, `Fragment::replace_files`, shared by `build_manifest` and the planner. ## Breaking changes Rust code that builds these with a struct literal stops compiling: - `Operation::DataReplacement` gains a required `data_change: bool`; `true` keeps the old behavior. - `TaskData` gains `kind`, `RewriteResult` gains `repacked_files`, and `CompactionOptions` gains `max_data_files_per_fragment` and `scope`. Use `TaskData::rewrite_fragments` or `repack_columns`, `repacked_files: None` and `..Default::default()`. Older serialized tasks, results and transactions still read, and an older worker rewrites a repack task's fragment instead. Java and Python only add API. ## Known limits - A run that rewrites and repacks commits two versions until composite transactions (#8644) land; if the repack fails, the rewrite stays. - A concurrent index build keeps coverage of repacked fragments only if its first commit attempt sees every version since its read, none a `Merge`. Segments committed with `commit_existing_index_segments` always lose it. - Grouping columns into files is left to #10509. ## How is it tested? | Test | What it pins | |---|---| | `repack_collapses_backfilled_files`, `repack_keeps_the_biggest_file` | backfilled files collapse in one commit, values and fragment ids unchanged; the layout over a limit of 2; a second run commits nothing | | `repack_keeps_deletions`, `repack_columns_preserves_data_overlay`, `repack_keeps_scalar_index`, `repack_columns_preserves_vector_index` | deleted rows keep their base values; overlays still shadow; BTree and IVF_PQ keep uuid and coverage and return the same rows | | `index_built_across_a_repack` | an index built before a repack keeps its coverage; a visible in-place update withdraws its fragment; a cleaned-up update or a `Merge` withdraws every repacked fragment | | `repack_against_concurrent_*`, `test_conflicts_data_replacement` | which concurrent changes a repack commits over and which make it retry | | `compaction_rewrites_and_repacks_in_one_run`, `commit_rejects_a_fragment_in_both_kinds_of_task`, `repack_commits_after_its_read_version_is_expired` | a mixed run commits `Rewrite` then `DataReplacement`; a fragment in both is refused; the repack still commits after its read version is expired | | `repack_never_adds_a_file`, `repack_merges_only_files_it_empties`, the lineage, blob, V1 and struct-header cases | the merge rules | | `compaction_plans_no_repack_by_default`, `repack_only_run_that_plans_nothing_is_refused`, `repack_is_not_planned_under_force_binary_copy`, `repack_counts_only_the_files_it_reads_against_the_byte_budget` | defaults, refusals and the byte budget | | `test_undrained_fri_allows_a_repack_only_plan`, `test_defer_index_remap_allows_a_repack_only_plan` | a repack-only plan isn't refused for pending remaps, with or without stable row ids, under `RepackColumns` or `All` | | `task_data_without_kind_rewrites_fragments`, `rewrite_result_without_repacked_files_is_a_rewrite`, `repack_tasks_run_distributed`, `testDeserializeTaskAndResultFromOlderVersion` (Java) | older tasks and results read as rewrites; repack tasks survive serde and commit together | | `test_data_replacement_data_change_roundtrips`, `test_data_replacement_applies_several_groups_to_one_fragment`, `test_data_replacement_data_change_round_trips` (Python) | `data_change` round-trips and only `true` withdraws coverage; several groups apply to one fragment | | `test_compact_files_repacks_columns`, `test_distributed_repack`, `test_repack_options_*`, `test_commit_leaves_dataset_at_the_rewrite_when_the_repack_fails` (Python), `testRepackColumns` (Java) | options, table config, task kind and layout stats through the bindings; the Python handle follows a landed rewrite | The repack task writes files the way @dshepelev15's #9291 did, and `Dataset::column_layout_stats` started in @Xuanwo's #8614. Thanks to both. Co-authored-by: dshepelev15 <[email protected]> Co-authored-by: Xuanwo <[email protected]>
This is the format part of #9604, split out the way
voting.mdasks: the protobuf field, the spec text, and the smallest library change that keeps the build green. The behavior lands with #9604.What changes in the format
DataReplacementgetsoptional bool data_change = 2, which says whether the new files change any value. When it is absent it means true, which is what every transaction written before the field meant.With
data_changefalse, the writer asserts that the new files hold the same base values as the files they replace, only laid out in different files. The commit then keeps index coverage of the replaced fields, leaves overlays alone because they still hold newer values, and doesn't move any row's last-updated-at version. A concurrent delete or update that removes a target fragment, or adrop_columnsof a replaced field, makes it retry instead of failing, and a concurrent index build on a replaced field no longer conflicts with it.The
DataReplacementsection also gains the rules the spec didn't spell out:Projectthat drops a replaced field conflicts, which the code already does but the spec didn't list.Why
Compaction in #9604 repacks a fragment's columns into fewer files. The values only move, so the three things a replacement does today are wrong for it: indexes would lose coverage of the fragment for no reason, tombstoning the overlays would make readers see the older base values again, and incremental readers would see every repacked row as updated. @wjones127 suggested this flag on #8614 (r3833888750), to match the
data_changeonAddDataFilein the composite transactions draft (#8644).The flag has to live in the transaction file, not only in the commit call, because concurrent writers read that file to resolve conflicts. Without it, an index build that races a repack of its column has to retry.
Compatibility
A commit with
data_changefalse produces a manifest that uses no new fields, so readers of the table are unaffected.A library that predates the field reads every replacement as a data change, as it does today. During conflict resolution that is the conservative reading: at worst it retries where a newer library wouldn't. The one case where it reads wrong is when such a library is handed a serialized
data_change: falsetransaction and commits it: it would tombstone overlays that the moved values don't supersede. Compaction doesn't do this, because the coordinator builds the transaction from the task results with its own library.#9604 writes the field only when it is false, so a data-changing replacement's transaction file stays the same as today.
Library change
proto.rsignores the field on read and leaves it unset on write. Until #9604 lands, every replacement is still applied as a data change, and the library doesn't yet support several groups for one fragment or groups with different fields, both of which the spec now allows.