Repository navigation
refactor(batch): remove Attrs from Batch - #33199
Merged
Merged
Conversation
A batch carries no column names. Names belong to whoever defines the columns (the plan, a table definition, a workspace entry) and travel beside the batch where an API needs them. - batch: drop the field, New, SetAttributes and GetSchema; add NewWithTypes and Types; SelectColumns, CloneSelectedColumns and InsertVector lose their name arguments; BatchToProtoBatch takes attrs. - codec: the stable format keeps its column-name section, written empty by default. MarshalBinaryWithNames / MarshalBinaryWithBufferAndNames write names for self-describing messages; WireNames reads them back. - engine: Relation.Write(ctx, bat, attrs) and Delete(ctx, bat, attrs, name). disttae workspace entries own their names and send TN exactly the names they sent before; TN WriteReq and catalog requests carry the api.Batch names; logtailreplay keeps them in ReplayBatch. - mixed-version CNs: relay inner blobs are written with their names; the remote-run sender writes the insert-S3 and remote-delete producers' fixed names on matching relay batches, so older coordinators still recognize them. New receivers recognize relay layouts by vector types. Refs matrixorigin#33182 Co-Authored-By: Claude Opus 5.5 <[email protected]>
fengttt
requested review from
LeftHandCold,
XuPeng-SH,
aptend,
aunjgr,
gouhongshen,
iamlinjunhong and
jiangxinmeng1
as code owners
November 25, 2026 02:51
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Contributor
|
This pull request is merged. |
A new CN decodes the column-name section an older CN writes, but no production code uses it. Consumers that read names back with WireNames now take them from what they already know: - multi_update flush and mergedelete name a relayed delete batch by its layout (colexec.RelayedDeleteAttrs: leading rowid is a row delete, otherwise tombstone object stats); inserts are always CNS3ResultAttrs. - The deletion and multi_update relay recognizers locate the object-stats column from the producer's fixed layout. - mergeblock names legacy in-memory data batches from the plan's table def (MergeBlock.Attrs). Producers still write names into relay blobs so older CNs keep working. WireNames remains for tests that pin that output. Tests now show wire names are ignored: blobs with no names or misleading ones give the same result. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o batch-remove-attrs
Resolve conflicts with the squashed matrixorigin#33184 (private extraBuf, lender-owned pins): take main's side and drop the batch Attrs uses this branch removes. Port the new ivfflat flush-ownership test to explicit proto names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fengttt
added a commit
to fengttt/matrixone
that referenced
this pull request
Nov 25, 2026
Brings PR matrixorigin#33199 onto this branch as one commit. Its commits: --- refactor(batch): remove Attrs from Batch A batch carries no column names. Names belong to whoever defines the columns (the plan, a table definition, a workspace entry) and travel beside the batch where an API needs them. - batch: drop the field, New, SetAttributes and GetSchema; add NewWithTypes and Types; SelectColumns, CloneSelectedColumns and InsertVector lose their name arguments; BatchToProtoBatch takes attrs. - codec: the stable format keeps its column-name section, written empty by default. MarshalBinaryWithNames / MarshalBinaryWithBufferAndNames write names for self-describing messages; WireNames reads them back. - engine: Relation.Write(ctx, bat, attrs) and Delete(ctx, bat, attrs, name). disttae workspace entries own their names and send TN exactly the names they sent before; TN WriteReq and catalog requests carry the api.Batch names; logtailreplay keeps them in ReplayBatch. - mixed-version CNs: relay inner blobs are written with their names; the remote-run sender writes the insert-S3 and remote-delete producers' fixed names on matching relay batches, so older coordinators still recognize them. New receivers recognize relay layouts by vector types. Refs matrixorigin#33182 --- refactor(batch): never read column names from the wire A new CN decodes the column-name section an older CN writes, but no production code uses it. Consumers that read names back with WireNames now take them from what they already know: - multi_update flush and mergedelete name a relayed delete batch by its layout (colexec.RelayedDeleteAttrs: leading rowid is a row delete, otherwise tombstone object stats); inserts are always CNS3ResultAttrs. - The deletion and multi_update relay recognizers locate the object-stats column from the producer's fixed layout. - mergeblock names legacy in-memory data batches from the plan's table def (MergeBlock.Attrs). Producers still write names into relay blobs so older CNs keep working. WireNames remains for tests that pin that output. Tests now show wire names are ignored: blobs with no names or misleading ones give the same result. --- fix(data branch): project only the current base relation's batches Base-side change batches come from several relations: the current base table (base layout, projected to the target layout with baseColToTarIdx) and historical relations from before an ALTER, whose handles already yield the target layout (projected by historicalDataBranchChangesHandle, or identical to it and left unwrapped). The hashdiff loop projected every base batch; main skipped the second projection by the target-layout names the batch carried. Without batch names, historical batches were projected again with the current base mapping, so after `alter table ... drop column` a diff read `amount` from the wrong column (BVT diff_output_as_altered_columns: "Column 'amount' cannot be null"). Move the projection onto a currentBaseChangesHandle that wraps only the current base relation's handle, so the decision comes from which relation a handle reads, not from the batch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The upstream merge brought code that appended these names to ctr.buf.Attrs. With Attrs gone from Batch those appends were removed, leaving the constants unused and failing SCA. Consumers locate the columns by index (AutoIncrementGeneratedColumn), not by name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
mo-bot review · Commit: "interrupted" |
This branch was successfully deployed
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.
What type of PR is this?
Which issue(s) this PR fixes:
Part of #33182 (batch cleanup, #32921).
What this PR does / why we need it:
Removes
Attrsfrombatch.Batch. Column names belong to whoever defines the columns: the plan, a table definition, or a workspace entry. They now travel beside the batch wherever an API needs them.Batch API
Attrsfield,New(attrs),SetAttributesandGetSchema.NewWithTypes(typs, mp)replacesNewWithSchema, andTypes()replacesGetSchema().SelectColumns,CloneSelectedColumnsandInsertVectorno longer take names.BatchToProtoBatch(bat, attrs)takes names explicitly.MarshalBinaryWithNamesandMarshalBinaryWithBufferAndNameswrite names for messages whose receiver identifies columns by name.WireNames(data)reads those names back without decoding the vectors. Only tests call it, to pin what this version writes for older CNs.Engine
Relation.Write(ctx, bat, attrs)andRelation.Delete(ctx, bat, attrs, name)now take the column names.api.Batchcarries exactly the names it carried before (TN keys columns by name).cmd_util.WriteReqand the catalog request structs carry theapi.Batchnames.AppendDataToTableandcontainers.ToTNBatchtake them as arguments.ReplayBatch. An empty name still marks a dropped column.OneSchemaBatchBuffer.Attrs().Mixed-version CN compatibility (the wire format is unchanged)
colexec.RelayedDeleteAttrs). Inserts are always the S3 block-info layout.MergeBlock.Attrs, the same rule insert uses).Behaviour changes for reviewers
currentBaseChangesHandle). Historical handles already yield the target layout, so the decision comes from which relation a handle reads, not from the batch. This fixes the BVTdiff_output_as_altered_columnsfailure.checkDupduplicate-key message read names from a batch that had none, which could panic. It now uses the entry's names.Validation
go build ./...,go vet ./pkg/... ./cmd/...and gofmt are clean.mo-cgo-test -count=1passes on all 88 changed packages (86 ok, 2 with no tests). After the decode-never-use follow-up, it passes again onpkg/sql/colexec/...,pkg/sql/compile/...andpkg/container/batch(72 packages).WireNamesround-trip, and empty names by default.🤖 Generated with Claude Code