Repository navigation
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 |
d60232a to
d6e4645
Compare
|
https://github.com/lance-format/lance/actions/runs/34446896028/job/102773541990?pr=9121 the failed case |
| relocates the declared rows counts as a change; transparent remapping through compaction is not | ||
| required. | ||
| - If the fragment's data files or deletion file differ from the read version, the declared cells | ||
| are changed. |
There was a problem hiding this comment.
Is it necessary to consider deletion to be a change? If we declare some cells and unrelated cells in the fragment get deleted then ideally that would not be an issue. Even if the declared cells are deleted, ideally that shouldn't cause recomputation of non-deleted values. The deleted/needlessly-computed values will be masked by the deletion vector.
There was a problem hiding this comment.
Good catch — the deletion part of "unchanged" is over-conservative. Deleting unrelated rows doesn't touch declared cells, and deleting declared cells masks them (stale value invisible), so neither should reject the commit. A precondition guards visible values, not fragment fingerprints.
Proposal: drop deletion from the change set. Rewrite, overlay, and schema evolution of protected fields stay violations; row masking by the delete vector is excluded. I'll relax #9118's deletion_file != check to row-granular and cover both cases in tests.
There was a problem hiding this comment.
Could you also update the description of this PR to match the diff?
d6e4645 to
918058c
Compare
918058c to
3d0fbf1
Compare
| - If the fragment no longer exists, the declared cells are changed. A concurrent rewrite that | ||
| relocates the declared rows counts as a change; transparent remapping through compaction is not | ||
| required. | ||
| - If the fragment's data files differ from the read version, the declared cells are changed. |
There was a problem hiding this comment.
Could we make file changes an allowed conservative check rather than a mandatory failure? Adding an unrelated column can change the file list without affecting protected cells. This would leave room for more precise checks later.
There was a problem hiding this comment.
Agreed — refined the contract in docs/src/format/table/transaction.md: a change is now keyed to data files carrying a declared field (replaced, removed, or with the declared field added/dropped). Files carrying no declared field may be added or removed (e.g. a concurrent column addition) without violating the precondition. Field-level checks can get more precise later within this rule; implementations may still over-reject at fragment granularity, but must never under-reject.
westonpace
left a comment
There was a problem hiding this comment.
I'm not against the feature but if there is a derived column that is being asynchronously filled, and there are also updates to the source values happening at the same time, will this be enough to solve the problem?
For example, this scenario is fixed:
- Begin derived column calculation at read version 5
- Update some values and create version 6
- Attempt to commit derived column calculation
But what about this scenario?:
- Begin derived column calculation at read version 5
- Commit derived column calculation as version 6
- Update some values to create version 7
The update itself wouldn't have any preconditions and so it would succeed. But the data is out of data. How do you plan to detect and resolve the out-of-syncness?
3d0fbf1 to
6b6129b
Compare
This feature guards the read-compute-write window only: it rejects a commit whose declared cells changed between the read version and publication. Scenario B — a source update landing after the derived column was published — is a different problem: materialization staleness. Once y is written at v6, any later update of x requires y to be recomputed, and a precondition on the derived commit cannot enforce that. |
6b6129b to
db95d87
Compare
wjones127
left a comment
There was a problem hiding this comment.
I like the overall idea, though I have two blocking comments.
| - **Degenerate entries.** An entry with an empty `field_ids` or an empty `rows` list declares no | ||
| cells; producers must not emit them. |
There was a problem hiding this comment.
question(blocking): does this need to be invalid? Or could it just be considered a no-op? If I say there's no fields or rows that are part of the precondition, it's just an empty one, and can be ignored, right? I ask because it would probably be more robust if we can safely ignore rather than have to error if we get something that's empty.
There was a problem hiding this comment.
Fixed: empty entries (empty field_ids or empty rows) are now no-ops — consumers must safely ignore them rather than error, so reads stay robust against degenerate entries. Producers should not emit them.
| /* The entire fragment is selected. Must be true when set. */ | ||
| bool full = 2; |
There was a problem hiding this comment.
suggestion(blocking): this currently means that full=false is can be written but is invalid. Could we make invalid states unrepresentable? For example, we could say if the bitmap is empty, then that implies full.
There was a problem hiding this comment.
Fixed: full is now a valueless google.protobuf.Empty message — present means the entire fragment is selected, so full = false is unrepresentable and consumers need no defensive rejection. I went with the valueless-message form rather than "empty bitmap implies full" so that an empty selection stays expressible through the bitmap variant.
db95d87 to
ee9b6f5
Compare
There was a problem hiding this comment.
✅ Gate recommendation: approve.
This revision addresses the empty-precondition concern and the full-selection concern: empty field or row lists are explicitly no-ops, and google.protobuf.Empty makes a full selection valueless while preserving a distinct empty bitmap selection. The protobuf, specification, and voting summary agree.
The field-aware change rules, schema-validity checks, and deletion-masking exception remain intact. The additive format stays inert for current writers, with enforcement following separately in #9118. Preconditions guard the read-compute-publish window; keeping derived values fresh after later source updates remains a separate concern.
Without read assertions, footprint conflicts give snapshot isolation, so UPDATE a=b and UPDATE b=a from one snapshot both commit. A writer whose values depend on a read declares it with AssertCellsUnchanged, whose RowSelection mirrors the legacy cell preconditions proposed in #9121. Co-Authored-By: Claude Opus 5.5 <[email protected]>
wjones127
left a comment
There was a problem hiding this comment.
This looks better, thanks. Please rebase and I'll get more PMC members to vote.
|
|
||
| /* Which rows of the fragment are selected. The selection is | ||
| * exhaustive: a variant that selects no rows is representable as an | ||
| * empty bitmap, and there is no way to encode `full = false`. |
There was a problem hiding this comment.
suggestion: Nice, this makes full = false unrepresentable. A proto3 oneof can still be unset, though. Please say in the comment and in the spec's "Invalid encodings" list that a RowSelection with neither full nor bitmap set is rejected as corrupt, or that it selects nothing. Either way the behavior is then defined for every consumer.
ee9b6f5 to
e9bbec7
Compare
Defines the Transaction.Precondition message: a declared set of cells (fields × physical row addresses) that must be unchanged relative to the transaction's read_version for the commit to land. Rows are encoded as per-fragment RowSelection entries (whole-fragment flag or portable Roaring bitmap of offsets). The spec pins the composition semantics (conjunctive), absent/empty behavior, invalid encoding handling, and the conservative meaning of "unchanged" — declared fields must still exist with unchanged data type and nullability, and over-rejection is permitted while under-rejection is forbidden. This is the format-vote half of lance-format#8976; it carries only the proto change, the docs/src/format specification, and compile-required edits. The builder and commit-loop implementation lands in a follow-up PR (lance-format#9118).
e9bbec7 to
c050737
Compare
Without read assertions, footprint conflicts give snapshot isolation, so UPDATE a=b and UPDATE b=a from one snapshot both commit. A writer whose values depend on a read declares it with AssertCellsUnchanged, whose RowSelection mirrors the legacy cell preconditions proposed in lance-format#9121. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@Xuanwo @westonpace can you review this pr again please, i have fixed the problems. |
Xuanwo
left a comment
There was a problem hiding this comment.
Thanks for clarifying that adding an unrelated column can leave protected cells unchanged. That addresses my earlier concern.
Since #8646 landed, the opt-in V2 AssertCellsUnchanged action already supports read-dependent commits with conservative fragment-level conflict checks. The concurrent column-swap and cleaned-history tests passed on the implementation now on main. Which caller needs the condition on a legacy operation, or needs disjoint writes in the same fragment to both commit? That would help establish whether to refine action 21 or introduce a second representation.
There is a concrete compatibility blocker across the two current heads. I encoded the same whole-fragment selection for fragment 3 using the two protobuf schemas. Neither #9121 nor #9118 could decode the other’s selection. An older descriptor could parse the enclosing Append while ignoring field 5. Please specify which committer must enforce a staged transaction’s conditions before publication. Reading an already committed transaction and handing a pending one to an older committer have different consequences.
feat(format): add cell preconditions to the transaction format
Part of #8976. Vote-only PR: proto change, format specification, and compile-required edits. The builder and commit-loop implementation is intentionally excluded and lands in the follow-up #9118, per the persisted-format change process.
Contract being accepted
A transaction may carry
preconditions: declarations that specific cells must be unchanged relative to the transaction'sread_versionwhen the commit lands. A cell is a(field, physical row address)pair; each precondition declares a set of cells as the cartesian product of field ids and a per-fragment row selection.Motivating case: read-compute-write workloads such as publishing a derived column
y = f(x). The staged values are only valid if the cells ofxthey were computed from still hold the same contents. Conflict compatibility cannot guard this — a read-x-write-ytransaction is compatible with a concurrent update ofx, and rebasing over it silently publishes stale values.Semantics fixed by this spec
The specification (
docs/src/format/table/transaction.md, new "Preconditions" section) pins the points that must be decided language-agnostically, before any implementation fixes them by accident:preconditionsis repeated and conjunctive: every entry must hold. A violation rejects the commit; it is never rebased over the changed cells.field_idsor emptyrowsdeclares no cells and is a no-op: consumers must safely ignore it rather than error on it (producers should not emit it). Consumers must reject negative field ids, duplicate fragment entries, or invalid Roaring bitmaps as corrupt transactions. ARowSelectionwhosecoverageoneof is unset selects no rows (a no-op, equivalent to an empty bitmap); producers must set exactly one variant. (full = falseis unrepresentable by construction — thefullvariant is a valuelessgoogle.protobuf.Emptymessage, so present always means selected.)read_versionstate, and checked at two levels. Field validity: every declared field must still exist with the same data type and nullability it had at the read version — a concurrentProjectthat drops the field while retaining its shared data file violates the precondition even when no manifest structure changed. Manifest structure: fragment removal, or any data file carrying a declared field being replaced / removed / with the declared field added or dropped from it, or any overlay affecting declared cells added / modified / removed / narrowed counts as a change. An overlay already present at the read version and unchanged does not. Files carrying no declared field may be added or removed (for example by a concurrent column addition) without violating the precondition. Masking exception: deletion-vector changes do not count as a change — a deleted row is masked, so any staged value on it is invisible to readers and does not need recomputation. Implementations may over-reject but must never under-reject.The
rowsencoding is fully specified in the proto: oneRowSelectionper fragment (fragment_id+ acoverageoneof offull— a valuelessgoogle.protobuf.Emptymessage, present means the entire fragment is selected — or a Roaring Bitmap portable-serialized bitmap of row offsets; if neither variant is set, the selection is empty and the entry is a no-op). Stable-row-id preconditions are explicitly reserved for a future revision.Compatibility
repeated Precondition preconditions = 5onTransaction; field 5 previously unused). Old readers ignore it; new readers see it absent for old writers. No field numbers reused or retyped.transaction.protois a stable persisted contract (transaction logs and inline manifest transactions), so this change requires the format-spec vote.