Skip to content

feat(transaction): action-based transaction wire format (Transaction V2) - #7954

Merged
wjones127 merged 1 commit into
mainfrom
will/oss-1530-draft-action-based-transaction
Nov 11, 2026
Merged

wjones127 merged 1 commit into
mainfrom
will/oss-1530-draft-action-based-transaction

Conversation

@wjones127

@wjones127 wjones127 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: In lance_table::format::pb, the generated pb::transaction::UpdateMap, UpdateMapEntry, KeyExistenceFilter, BloomFilter, ExactKeySetFilter, and key_existence_filter::Data moved to the new lance_table::format::pb_actions module, and pb::transaction::Operation gains a CompositeOperation variant, so exhaustive matches on it must handle it. The wire encoding of existing messages is unchanged.

Defines the wire format for action-based transactions (Transaction V2): a CompositeOperation that replaces the single legacy Operation with an ordered list of granular, composable Action deltas. This is the format change only — read-side fail-closed, no write path. Every protobuf and spec change the implementation stack needs lands here, so the format is a single vote; the PRs stacked on top of it change no .proto file or format doc.

Layout

The V2 vocabulary lives in its own files under protos/transaction/, and its messages in their own lance.transaction package, apart from the table messages in lance.table (which already has an unrelated AddDataFile, a fragment-tree mutation). In Rust, the generated code is lance_table::format::pb_actions.

  • actions.proto — the V2 vocabulary (Ref, CompositeOperation, UserStep, Action + the action messages), with the design rationale summarized in an in-tree file header so it stands on its own.
  • common.proto — shared building blocks (UpdateMap, KeyExistenceFilter, …) referenced by both legacy operations and V2 actions, promoted from nested Transaction messages to top-level lance.transaction messages to avoid a circular import. Wire-compatible: field numbers unchanged and none are Any-packed.
  • transaction.proto — moved into the directory; keeps the Transaction envelope, legacy operations, and the new composite_operation oneof arm (field 116).

What's in the wire format

CompositeOperation { [UserStep] }
UserStep      { description, [Action] }        // human-readable step; survives squash
Action        { oneof of 24 actions }
Ref           { committed: uint64 | local: uint32 }   // one ref type for field/fragment/base ids

Design principles (fully documented in actions.proto):

  • Deltas, not post-images — actions record the change (AddDataFile, TombstoneFieldData), so compound commits and branch merge fall out uniformly.
  • Minting vs. reference-stable — minted ids (field/fragment/base) carry a Local token via a single Ref and relocate on merge/rebase; reference-stable changes key off stable coordinates and keep a post-image with a derivable delta.
  • Field-level schema — AddField / DropField / identity-preserving AlterField (rename and nullability; logical_type is reserved and rejected at apply, so a cast is DropField + AddField + data). No wholesale SetSchema.
  • Index segments — AddIndexSegment / RemoveIndexSegment / AdjustIndexCoverage (a logical index is the segments sharing a name; per-segment config duplication is a pre-existing limitation this draft doesn't fix).
  • Assertions — AssertUniqueKeys carries merge-insert's non-derivable key-existence filter as an explicit precondition.
  • Off the wire — computed conflict footprints and large derivable row-level deltas (deletion affected-rows) are recomputed at conflict time, not serialized. The rows a RefreshRowVersionMetadata restamps are on the wire, as a per-fragment RowSelection (whole fragment or an offsets bitmap), because they can't be derived from the files a change writes.
  • Additive-safe — message identities and core mutation fields are pinned; discoveries land as added optional fields.

Settled by the implementation

These started out in the PRs stacked above and were pulled down here so the format is voted on once:

  • UserOperation becomes CompositeOperation, naming what distinguishes it from the other operations, and loses its description — the per-step UserStep.description is what keeps history readable. UserAction is renamed UserStep (field numbers unchanged), so the step a user recognizes is not confused with the Actions it holds.
  • The field actions reference fields by Ref, so an action can name a field the same operation is minting.
  • AddIndexSegment gains base, created_at, and dataset_version, and its covered_fragments becomes an optional wrapper rather than a bare repeated. A bare repeated field cannot distinguish "no coverage recorded" — what the MemWAL and fragment-reuse indices carry, and what the query path treats as "serve this segment" — from "covers no fragment", which it treats as "skip it". dataset_version is a correctness gate rather than provenance: an overlay committed at or before it counts as already folded into the index.
  • RemoveIndexSegment and AdjustIndexCoverage carry the name of the logical index the segment belongs to, which is what conflict detection compares.
  • The update_compacted_ss_tables oneof arm is named to match its UpdateCompactedSsTables message, which is what the action vocabulary keys the wire encoding off.
  • AddFragment carries a spilled row lineage sequence as a RowLineageColumn arm, exactly as DataFragment does since feat(format): define hidden row lineage columns #9253: the sequence is a hidden column of one of the data files the fragment's AddDataFile actions add.
  • Doc-only: SetDeletionFile.fragment is committed-only because the deletion file path embeds the fragment id; an explicit AddIndexSegment.dataset_version must equal the read version for now; ResetTable discards actions before it in the same operation.

Worked examples

Add a column and its data in one commit

A new field has no id until the commit lands. The data files name it by the token its AddField minted, so readers never see the column without its data:

CompositeOperation
└── UserStep "add column b"
    ├── AddField    { local: 0, parent: none, def: b: int32 }
    ├── AddDataFile { fragment: Committed(0), field_ids: [Local(0)], file: b-0.lance }
    └── AddDataFile { fragment: Committed(1), field_ids: [Local(0)], file: b-1.lance }

At apply, Local(0) resolves to the next field id, and both files are stamped with it. Replaying the set onto a newer version re-resolves the token against that version's counter.

Caveats

  • Append + delete, and append + index, need a reservation commit first. A deletion file's path embeds the fragment id (_deletions/{fragment_id}-{read_version}-{id}.{ext}), and apply does no IO, so SetDeletionFile takes a committed id. An index segment's files likewise record real fragment ids and row addresses. Commit ReserveFragmentIds first. Then write the fragments as Ref::Committed(reserved_id) and build the deletion file or segment against those ids.
  • Indexing a column added in the same commit is not possible with today's builders. AddIndexSegment.fields accepts Local(0), but every index builder reads the column through the committed schema. Commit the column first, then build and add the segment.

Library changes (minimal, fail-closed)

Read-side rejection only:

  • One arm in TryFrom<pb::Transaction> returns Error::NotSupported for a CompositeOperation, with a comment forbidding lenient parsing (the try_collect contract aborts a concurrent V2 commit rather than silently skipping it).
  • Regression test test_composite_operation_rejected_on_load.
  • lance-tools manifest output names a CompositeOperation and counts its steps and actions, since its operation match is exhaustive.

No Operation enum variant, no apply / translation / conflict resolution, no write path, no Cargo feature gate, no Python/Java changes.

Verification

lance-table + lance build; new test passes; cargo fmt --all and cargo clippy -p lance-table -p lance --tests -- -D warnings clean.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (2)
  • WIP
  • Draft

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: d6c3e873-ac4a-40f7-89f6-e462d4db9be4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch will/oss-1530-draft-action-based-transaction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Important

This PR touches the Lance format specification.

Substantive changes to the format specification — the .proto definitions
and the spec docs under docs/src/format/ — require a PMC vote before merge.
Minor edits such as typo fixes, wording, or formatting are excluded; use your
judgment.

If this is a meaningful format change:

  • Start a vote following the Lance community voting process.
    Format specification modifications need 3 binding +1 votes (excluding the
    proposer), held on GitHub Discussions, with a minimum voting period of 1 week.
  • Once the vote passes, link the completed vote in this PR. It should not be
    merged until the vote is linked.

@github-actions github-actions Bot added A-format On-disk format: protos and format spec docs enhancement New feature or request labels Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.75510% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance-table/src/format/key_existence.rs 44.44% 5 Missing ⚠️
rust/lance-table/src/transaction/proto.rs 97.50% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@wjones127
wjones127 force-pushed the will/oss-1530-draft-action-based-transaction branch from 19ac8e0 to f53d35a Compare July 28, 2026 22:41
@wjones127
wjones127 changed the base branch from main to refactor/transaction-module-split July 28, 2026 22:41
@wjones127
wjones127 force-pushed the will/oss-1530-draft-action-based-transaction branch from f53d35a to 5422956 Compare July 28, 2026 23:21
Base automatically changed from refactor/transaction-module-split to main August 19, 2026 18:38
@wjones127
wjones127 force-pushed the will/oss-1530-draft-action-based-transaction branch from 5422956 to 132c3b4 Compare August 19, 2026 20:30
@wjones127 wjones127 changed the title feat(transaction): draft action-based transaction wire format (Transaction V2) feat(transaction): action-based transaction wire format (Transaction V2) Aug 19, 2026
@wjones127
wjones127 force-pushed the will/oss-1530-draft-action-based-transaction branch from 4734fe4 to ddafb45 Compare September 8, 2026 19:51
@github-actions github-actions Bot added A-ci CI / build workflows format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). labels Sep 8, 2026
@wjones127

Copy link
Copy Markdown
Contributor Author

Self-review pass (polish-pr), 2026-09-20

Decision

No code changes. The diff is mechanical apart from the new wire schema and one fail-closed decode arm; the self-review found nothing here that should be auto-applied, because every finding either pins a proto field number or reshapes a message, and the field numbers ripple through all three PRs above this one.

Status

Open. The items below want a decision before the vote pins the tags.

Open questions

Wire schema:

  • CompositeOperation duplicates uuid and read_version, which Transaction already carries. The comment says uuid "matches Transaction.uuid semantics", which is the question rather than the answer: two copies that can disagree, with no stated rule for which wins. Drop them, or state that the outer fields are authoritative.
  • AssertUniqueKeys embeds KeyExistenceFilter and then documents filter.field_ids as permanently ignored and left empty. A wire field that must be empty and must not be read is a trap once the tag is pinned. Splitting a payload message holding just the oneof { ExactKeySetFilter, BloomFilter } would let both sides carry their own field list.
  • Ref is a generic top-level name in lance.table and a Rust keyword, so every generated call site is pb::r#ref::Kind. IdRef would also say what it refers to.
  • Ref.committed is uint64, but the id spaces it names are not all that. Fragment id is uint64, base id is uint32, field id is int32 — and a field id has negative sentinels (-1 unassigned, -2 tombstoned, the value TombstoneFieldData writes). Worth stating that the committed value is the non-negative id only, and what apply does with an out-of-range one.
  • The Ref-vs-committed-id line is drawn inconsistently across the fragment actions. SetDeletionFile.fragment is a bare uint64 with a good reason. RefreshRowVersionMetadata.fragment_ids and AdjustIndexCoverage.remove_fragments are bare and unexplained. RemoveFragment, TombstoneFieldData, AddOverlays and DropField take a Ref — and AddOverlays's own comment says it targets committed fragments.
  • ReserveFragmentIds.count is uint32 while ReserveRowIds.count is uint64, in two messages the file presents as counterparts.
  • RemoveIndexSegment.name is derivable from the segment uuid at the read version; the comment justifies it only as an apply-time cross-check, which is worth saying outright.
  • AddFragment restates six DataFragment fields rather than embedding it, unlike AddField.def and AddBase.base, with no stated reason.
  • The Action oneof tags no longer follow reading order (add_data_file = 2 after add_field = 3; reserve_row_ids = 20 before assert_unique_keys = 19).
  • AddIndexSegment's uuid / name / index_details / index_version and ConfigUpdate's three optional UpdateMap fields are the undocumented ones in otherwise well-documented messages; protos/AGENTS.md asks optional fields to state what absent means.

Tests and process:

  • decode_inline_transaction must keep returning None for a CompositeOperation, so that opening a dataset whose newest version was written by a newer Lance still works. This PR now depends on that fail-open half of the split and nothing pins it; the function is private and takes &[u8], so a unit test at the bottom of dataset.rs is a few lines.
  • test_only_persisted_protos_are_format_changes is blind to a stale glob. A protos/ glob matching nothing contributes nothing to the resolved set, so re-adding the now-deleted protos/transaction.proto to the config still passes — which is the failure mode this PR's config edit exists to repair. Asserting that every protos/-prefixed glob matches at least one file closes it.
  • Nothing exercises the pb conversions for the messages hoisted out of Transaction into lance.table (UpdateMap, KeyExistenceFilter, BloomFilter, ExactKeySetFilter). The move is wire-compatible on inspection — field numbers and embedded encodings unchanged, none carried in a google.protobuf.Any — but a round-trip test in key_existence.rs would prove it, and would also cover the zero-means-default branch.
  • protos/AGENTS.md asks a persisted-format proto change to land with the matching docs/src/format/ change. The only docs edit here is a link retarget, and CompositeOperation is not described in docs/src/format at all — worth either a short "Transaction V2 (draft)" subsection or a line in the PR description saying the spec text lands with the vote.

🤖 Generated with Claude Code

@wjones127

Copy link
Copy Markdown
Contributor Author

Legacy conflict characterization run against this PR (burn-down item 14)

Decision

#9220's characterization suite passes unchanged on this PR: 42 passed, 0 failed, 6 ignored, ~2s.

Status

Verified 2026-09-20. Nothing in the stack changes legacy conflict behaviour.

Options and criteria

The suite's branch (will/legacy-conflict-characterization, base 8cdffd30e) sits 56 commits ahead of this stack's base (93ba1d20c), so the suite does not compile on the stack as-is — FileFragment::write_overlay, which scenarios.rs uses, does not exist at the older base. That is base skew, not a behavioural difference.

Method: for each PR, a throwaway branch off the PR head, merge 8cdffd30e (clean, no conflicts), cherry-pick the suite's five commits, cargo test -p lance --lib conflict_matrix. Throwaway branches deleted afterwards; nothing here is pushed.

Results, all four layers:

PR Result
#7954 42 passed, 0 failed, 6 ignored
#8644 42 passed, 0 failed, 6 ignored
#8645 42 passed, 0 failed, 6 ignored
#8646 42 passed, 0 failed, 6 ignored

#8644 is the layer that matters most here — it is the one that touches conflict_resolver.rs, adding the fail-closed CompositeOperation arm to every check_*_txn and spelling out check_add_bases_txn's wildcard. The suite covers exactly that file and is unaffected.

Open questions

  • The suite's 6 ignored cases are ignored on its own branch too; this run does not change them.
  • The stack will need a rebase onto current upstream/main before merge regardless; the clean merge above is evidence that rebase is not expected to be eventful.

🤖 Generated with Claude Code

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 26, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

Comment thread docs/src/format/table/transaction.md Resolved
Comment thread docs/src/format/table/transaction.md Resolved
Comment thread docs/src/format/table/transaction.md Resolved
Comment thread docs/src/format/table/transaction.md Resolved
Comment thread docs/src/format/table/transaction.md Resolved
Comment thread docs/src/format/table/transaction.md Resolved
Comment thread docs/src/format/table/transaction.md Resolved
Comment thread protos/transaction/actions.proto Resolved
lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

@geruh geruh 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.

Went through this and the stacked PRs, and this LGTM!

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

lance-gatekeeper[bot]

This comment was marked as outdated.

@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.

Delta actions with relocatable IDs remain a reasonable foundation for compound commits and replay. This rebase preserves the assessed wire contract and adds inspection-only CompositeOperation summaries to lance-tools, reporting step and action counts without enabling V2 execution. Acceptance makes the current wire field numbers and meanings durable compatibility commitments.

This remains a format-only change, with no V2 writer or executor. Core transaction loads fail closed. Merged #9482 supplies manifest field 23, allowing unaware readers to open and scan while transaction-history reads and concurrent older writers can fail safely. The earlier findings remain addressed.

The write-path contract still includes:

  • Required-field coverage after data-file or required-schema changes; committed references within the read version’s allocation bounds, including earlier reservations; duplicate local-token rejection within each ID space; correct drop ordering and index-coverage preconditions. Independent keyed/carried declarations must lower without loss, rejecting overlap until the manifest supports it.
  • Absent data_change means true. Paired data_change=false re-encodes preserve raw base values without applying overlays, retain overlays, index coverage and row versions, and commute with overlays, matching merged #9705. Re-encodes still count as writes against cell/key assertions.
  • Partial row-version refresh uses whole-fragment or bitmap selections, preserves unselected versions, leaves created_at untouched, and defaults previously untracked rows to version 1.
  • Fragment-reuse append/trim uses the latest history, excludes stable-row-ID indices in either admission order, and is discarded by ResetTable. Missing translation falls back to scanning. Direct coverage takes precedence over translated coverage, as in merged #9068 and #9107; overlapping metadata can remain for maintenance.

The author’s chosen follow-up for the MemWAL incarnation-identity gap remains an accepted, non-blocking limitation of this format-only vote; incarnation fencing is still needed when enabling a V2 writer.

Runtime enforcement of these contracts—including bitmap/row bounds, mapping payloads and replay/trim races—remains unverified here, not a merge prerequisite for a PR that cannot write V2 transactions. Read-derived writes still need AssertCellsUnchanged. Adoption costs remain an earlier ID-reservation commit for append-plus-index/delete, and per-field metadata overhead for wide appends.

The new renderer has a focused regression test, but I could not execute it locally because the repository’s pinned Rust toolchain is unavailable in this environment.

@westonpace westonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a lot here so this is partially a YOLO review. We will probably have some tweaks and lessons learned with time but I think the overall premise of multiple operations separate from user intention is the direction we want to head.

Comment thread .github/labeler-area.yml
- "protos/table.proto"
- "protos/fragment_metadata.proto"
- "protos/transaction.proto"
- "protos/transaction/*.proto"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will this miss transaction.proto now? I don't think that file is entirely removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

transaction.proto has been moved to protos/transaction/transaction.proto

Comment on lines -210 to +212
writer [feature flags](../../table/versioning.md#current-feature-flags) to guard against this.
writer [feature flags](../../table/versioning.md#current-feature-flags) to guard against this,
whatever the FRI index version. A tagged history on such a table sets it alongside
`FLAG_FRAGMENT_REUSE_INDEX`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this change making things more clear?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Comment on lines +214 to +217
FRI translates row addresses, so it applies only to indices that store row addresses. Tagged
histories (`index_version >= 1`) are allowed on tables with stable row IDs, but an index that
stores stable row IDs must not coexist with a tagged entry: writers must refuse to record a
transition while such an index exists, and to add such an index while a tagged entry exists.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we want to block row-id-domain-index and FRI regardless of FRI version. This paragraph makes it seem like we only block tagged FRIs.


A `CompositeOperation` holds `UserStep`s, each a human-recognizable step with
a description, which in turn hold the granular `Action`s applied to the
manifest. The two levels support multi-statement transactions: each statement

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should be careful about the term "multi-statement transaction". The classical multi-statement transaction allows for reads after earlier steps in the transaction have executed. This leads to phenomenon like "repeatable reads", "phantom reads", etc. and the definition of classic isolation levels.

I don't think that is what is being proposed here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are actually moving towards that. A big part of the changes in these protos is about referring to changes earlier in the transaction, such as the idea of "local" ids in the transaction. Drew is working on the library side of this, where we'll actually be able to do things like make updates and create indexes referencing data added or modified during a transaction. So the "multi-statement transaction" reference is intentional.

Comment thread docs/src/format/table/transaction.md Outdated
Comment on lines +660 to +664
Every fragment must store data for each required field, one that is
non-nullable and has only non-nullable ancestors; a fragment without it would
read the field back as nulls. Apply checks each fragment whose data files the
operation sets. When the operation makes a field required, by adding it as
non-nullable or by making it non-nullable, apply checks every fragment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't harmful but seems out of place or slightly extraneous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. i'll remove it.

Comment thread docs/src/format/table/transaction.md Outdated
Comment on lines +669 to +678
One vocabulary detail is a format contract rather than an implementation
choice. `AddIndexSegment.fields` names only the columns the segment is keyed
on, and `covering_fields` is an independent declaration of the columns whose
values it carries, so the segment's dependency set is the union of the two.
This is the contract an index action targets, not the legacy one where
`IndexMetadata.fields` means keyed columns followed by carried columns. A
declaration whose two lists overlap can only be represented by a manifest
declaring `FLAG_INDEPENDENT_COVERING_FIELDS`; until a release implements that
flag, apply rejects the overlapping form and lowers a disjoint one to the
legacy subset representation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again, slightly related but also slightly extraneous. Can we add a validation section or something that lists validation requirements run against any kind of transaction (composite or otherwise)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a Validation section under Commit Protocol listing the checks every commit runs, legacy or composite (required-field data, non-empty data files, unique fragment IDs, field ID allocation), in eb02eb5. Dropped the covering-fields paragraph; AddIndexSegment's docs in actions.proto and "Covering-field contracts" in index/index.md already cover it.

Comment on lines +680 to +685
Actions apply in order, with one exception: `ReserveFragmentIds` and
`ReserveRowIds` are summed and taken after the operation's own mints, wherever
they appear. A reservation creates nothing another action can reference, so
this has no other visible effect within the operation, and a fragment can claim
a reserved id only from an earlier commit's reservation. `ResetTable` discards
objects but never rewinds the id counters.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you think placeholders remove the need for reserving fragment ids entirely?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. In fact, we should deprecate reservations. It's impossible for us to validate a later transaction was done by the same system that did a reservation, so it's possible with reservations to create duplicate fragment ids. Not something I'm super worried about, but it's a fragile point in the current design. Something gatefixer has complained about.

Comment thread docs/src/format/table/transaction.md Outdated
Comment on lines +687 to +691
`data_change` is per action, and absent means true. `false` asserts the action changes no row's
values: the rows it adds, removes, or rebinds are the same logical rows with
the same values before and after, as when compaction moves rows or a column
file is re-encoded. Change-data-capture readers emit rows only from
`data_change = true` actions, and one operation may mix both.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's slightly odd that "absent means true" but maybe too late in the game to rename to something like data_unchanged or data_preserved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I see. This is because protobuf defaults to false? I'm open to changing that now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in d2d0be1: actions now carry a plain bool data_unchanged (default false = changed), so omitting it is still the conservative reading without relying on presence.

Comment on lines +760 to +782
* An assertion (precondition), not a delta: the declared cells -- the cross
* product of `fields` and `rows` -- hold the values they held at the
* operation's read version. Conflict detection otherwise compares only what
* two operations write (snapshot isolation), so a writer whose values depend
* on what it read (an update computing `a = b`) must declare the read here.
*
* "Unchanged" follows the cell preconditions proposed for the legacy
* transaction (#9121): a cell counts as changed if its field was dropped or its
* definition altered, its fragment was removed, the data file carrying its
* field was replaced (a re-encode included), or an overlay touching it was
* added. A change to the deletion
* vector does not count. Implementations may over-reject (e.g. at fragment
* granularity) but must never under-reject.
*/
message AssertCellsUnchanged {
/*
* The fields read. Committed schema field ids only: a field minted in the
* same operation has no prior value.
*/
repeated FieldRef fields = 1;
// The rows read, one entry per fragment.
repeated RowSelection rows = 2;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this new or have I just fallen behind on what actions we have?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is new. It's shaped like the proposal in #9121


A `CompositeOperation` holds `UserStep`s, each a human-recognizable step with
a description, which in turn hold the granular `Action`s applied to the
manifest. The two levels support multi-statement transactions: each statement

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are actually moving towards that. A big part of the changes in these protos is about referring to changes earlier in the transaction, such as the idea of "local" ids in the transaction. Drew is working on the library side of this, where we'll actually be able to do things like make updates and create indexes referencing data added or modified during a transaction. So the "multi-statement transaction" reference is intentional.

Comment thread docs/src/format/table/transaction.md Outdated
Comment on lines +660 to +664
Every fragment must store data for each required field, one that is
non-nullable and has only non-nullable ancestors; a fragment without it would
read the field back as nulls. Apply checks each fragment whose data files the
operation sets. When the operation makes a field required, by adding it as
non-nullable or by making it non-nullable, apply checks every fragment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. i'll remove it.

Comment thread docs/src/format/table/transaction.md Resolved
Comment on lines +680 to +685
Actions apply in order, with one exception: `ReserveFragmentIds` and
`ReserveRowIds` are summed and taken after the operation's own mints, wherever
they appear. A reservation creates nothing another action can reference, so
this has no other visible effect within the operation, and a fragment can claim
a reserved id only from an earlier commit's reservation. `ResetTable` discards
objects but never rewinds the id counters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. In fact, we should deprecate reservations. It's impossible for us to validate a later transaction was done by the same system that did a reservation, so it's possible with reservations to create duplicate fragment ids. Not something I'm super worried about, but it's a fragile point in the current design. Something gatefixer has complained about.

Comment thread docs/src/format/table/transaction.md Outdated
Comment on lines +687 to +691
`data_change` is per action, and absent means true. `false` asserts the action changes no row's
values: the rows it adds, removes, or rebinds are the same logical rows with
the same values before and after, as when compaction moves rows or a column
file is re-encoded. Change-data-capture readers emit rows only from
`data_change = true` actions, and one operation may mix both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I see. This is because protobuf defaults to false? I'm open to changing that now.

Comment on lines +760 to +782
* An assertion (precondition), not a delta: the declared cells -- the cross
* product of `fields` and `rows` -- hold the values they held at the
* operation's read version. Conflict detection otherwise compares only what
* two operations write (snapshot isolation), so a writer whose values depend
* on what it read (an update computing `a = b`) must declare the read here.
*
* "Unchanged" follows the cell preconditions proposed for the legacy
* transaction (#9121): a cell counts as changed if its field was dropped or its
* definition altered, its fragment was removed, the data file carrying its
* field was replaced (a re-encode included), or an overlay touching it was
* added. A change to the deletion
* vector does not count. Implementations may over-reject (e.g. at fragment
* granularity) but must never under-reject.
*/
message AssertCellsUnchanged {
/*
* The fields read. Committed schema field ids only: a field minted in the
* same operation has no prior value.
*/
repeated FieldRef fields = 1;
// The rows read, one entry per fragment.
repeated RowSelection rows = 2;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is new. It's shaped like the proposal in #9121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ci CI / build workflows A-format On-disk format: protos and format spec docs breaking-change 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.

5 participants