patch_table: positioned index adds (after / first)#161
Merged
Conversation
The index analogue of #159's positioned column adds, unblocking the last object standing from the once-only work: posthog.sharded_events, whose per-env minmax_mat_* skip indexes interleave mid-list and could only be appended by a patch. A patch index add takes after = "<name>" or first = true, with the same semantics as columns: mutually exclusive, append by default, resolved against the post-previous-op state (drops apply first, so after may name an index added earlier in the same patch and a dropped/unknown target errors, while a positioned drop+add redefines an index at a position — drop+add is already the sanctioned redefine path, and a redefine lands where you put it). Placement is transient and cleared on application, so the composed table renders byte-identical to the flat declaration; a declared table index carrying after/first errors at resolve, including via abstract-base inheritance. The column and index paths share one insertPos helper; the column error messages are unchanged. Closes #160
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #160 — the index analogue of #159, unblocking
posthog.sharded_events(the last of the 12 order-blocked objects; ~380 columns, per-envminmax_mat_*skip indexes interleaved mid-list).Same semantics as #159's column placement, per the issue:
after/firston a patchindexadd; mutually exclusive; neither keeps the append default.aftermay name an index added earlier in the same patch and a dropped/unknown target errors. A positioned drop+add redefines an index at a position — drop+add is already the sanctioned redefine path, and a redefine lands where you put it.diff:"-"): the composed table renders byte-identical to the flat declaration — asserted by test and confirmed withcmpagainst the built binary.The column and index paths now share one
insertPoshelper (column error messages unchanged — #159's tests pass untouched).Plan doc:
docs/plans/2026-07-18-patch-index-position.md; docs updated in thepatch_tablereference (index bullet + example), README, CLAUDE.md.Test plan
sharded_eventsscenario in miniature with byte-parity (Write(base+patch)equalsWrite(flat));first+ chainedafter+ positioned drop+add redefine in one patch with cleared placement; error paths (both set, unknown target, target dropped in the same patch, declared-index placement, abstract-base inheritance)go test -race ./internal/... ./cmd/... ./test— all green;gofmt -scleancmpbyte-identical to the flat declaration