Repository navigation
[Compatibility]: preserve opaque values in JSON aggregates - #28947
VioletQwQ-0 wants to merge 33 commits into
Conversation
ec323c9 to
ad0672f
Compare
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? |
|
@aptend @XuPeng-SH Could you re-review draft head This head incorporates the landed CRC32 prerequisite (#28935). It removes the feature-specific MORPC version, worker probes, and fallback, and uses the existing tagged JSON encoding for opaque aggregate values. Please confirm whether this resolves the earlier protocol-allocation and mixed-version concerns under that policy. The existing review threads remain open for your disposition. Required CI passed for this head. Deployment acceptance is still pending: the same-binary multi-CN run must show remote partial/final aggregation, exact opaque subtype and payload, and actual spill. Historical mixed-binary runs cover earlier heads. |
… HEAD # Conflicts: # pkg/sql/colexec/aggexec/direct_methods_edge_test.go
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
🛑 Queue command cancelledTick the box to add this pull request to the merge queue (same as
|
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: fcc2c89d3ac430c1e27cfd527152c8145acde185
Assessment: request_changes
The opaque encoding preserves the existing byte format, and the historical mixed-version objections are superseded by the pinned shutdown-upgrade policy. The new aggregate path nevertheless repeats type and BIT-width dispatch inside row loops, contrary to the repository’s mandatory type-dispatch rule.
Model: gpt-6.1-terra / max
Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45
- P2
pkg/sql/jsonvalue/value.go:82: An accounted JSON_ARRAYAGG or JSON_OBJECTAGG processes non-null BIT, BINARY, VARBINARY, or BLOB values.
Impact: The new helpers repeatedly select the opaque subtype and, for BIT, inspect its width for every row. The accounted path performs these decisions during both preflight and fill, for sizing and appending. This is a policy and design violation with repeated per-row work; no end-to-end performance regression has been measured.
Evidence: OpaqueValueSize and AppendOpaqueValue dispatch at value.go:82 and value.go:111-115. They are called inside the preflight loop at pkg/sql/colexec/aggexec/capacity_preflight.go:3028 and the fill loop at pkg/sql/colexec/aggexec/jsonagg2.go:767. The pinned .agents/skills/mo-dev/references/type-dispatch.md requires type and width decisions to be resolved before vector loops. Select the opaque sizing and encoding operations, including BIT width, once per input vector or batch while preserving null handling and allocation preflight.
Validation:
-
The private /tmp and loopback preflight passed; receipt checks/1796118527861776887-3.json.
-
A source-extracted, standard-library-only probe passed 350 byte-identity, exact-size, prefix, and reserved-capacity cases plus overflow controls; receipt checks/1796118857714342412-3.json and opaque-codec-probe.log. It did not execute the MatrixOne package.
-
git diff --check passed for the assigned merge-base and head; receipt checks/1796118921458679104-3.json and diff-check.log.
-
The frozen CI snapshot reports successful UT, SCA, multi-CN BVT, and CI Required jobs. The PR body reports exact-head package tests and the two specified single-CN SQL cases.
Limitations:
-
Local package tests did not run: matching native libraries were absent, the installed Go version was below the required 1.27.1, and automatic toolchain download timed out. The retained logs and receipts record these environment diagnostics.
-
The author reports deployed same-binary remote partial/final and physical-spill acceptance as pending; case-level CI logs were not included in the supplied evidence.
🛑 The queue request has been cancelled: new commits were pushedDetails@VioletQwQ-0 pushed to this pull request after |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 06ab5f47a9f847a75cce3333adff2dfedfd444f8
Assessment: request_changes
The change reuses the existing opaque encoding and aggregate state machinery, and it resolves the earlier per-row dispatch concern for the new opaque batch path. One separate mandatory type-dispatch policy violation remains. Historical mixed-version and protocol-allocation objections are superseded by the pinned shutdown-upgrade policy.
Model: gpt-6.1-terra / max
Session: 01a22b07-00b6-7e32-b0a1-3099d0b867c7 · slot 1 · generation 39
- P2
pkg/sql/colexec/aggexec/jsonagg2.go:512: Adding BIT and opaque binary conversion to the general JSON aggregate type switches at this location and at lines 682 and 1295.
Impact: The pinned G-TYPESWITCH rule prohibits extending general type switches outside types/vector. The new arms also maintain redundant scalar conversion paths and wrapper APIs: the production aggregate entry points already select the vector-bound opaque encoder before reaching these switches. This is a policy and design finding; no per-row performance regression is claimed for the current opaque batch path.
Evidence: The pinned .agents/skills/mo-dev/references/type-dispatch.md explicitly prohibits extending a general switch even for one missing type. jsonAggregateValueEncoder and jsonAggregateValueBuilder select NewOpaqueValueEncoder first at jsonagg2.go:760 and :784, while the new arms call single-row wrappers that construct an encoder in pkg/sql/jsonvalue/value.go:159. Remove the added opaque arms and unused wrappers, and exercise the bound encoder in the affected tests while preserving the existing non-opaque behavior.
Validation:
-
Private /tmp and loopback preflight passed; receipt checks/1796127209311549794-3.json.
-
Focused bytejson, jsonvalue, aggexec and planner-function tests passed at the assigned head, including opaque partial merge and spill-codec tests; receipt checks/1796127925328838042-3.json and focused-go.log.
-
An independent merge-base wire-format oracle passed, as did a prepared-parameter specialization probe for BIT and the binary types; receipts checks/1796128036541913350-3.json and checks/1796128394115284082-3.json.
-
TestTypeSwitchFamilies and git diff --check passed; receipts checks/1796128126449569740-3.json and checks/1796128431351599572-6.json. The type-family guard does not enforce the separate prohibition on extending general switches.
-
All 77 discussion items are recorded in attempt-1/discussion-assessment.json.
Limitations:
- The reviewer did not run a SQL service, a race suite, or same-head multi-CN physical-spill execution. The author reports the grouped and window SQL cases passed and deployed multi-CN and physical-spill acceptance remains pending.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: a657c253e99599e7215b04336e8d0db3759d514f
Assessment: request_changes
The earlier general type-switch additions are removed, and the opaque encoding and focused aggregate tests pass. A narrower subtype-dependent decision remains inside the row-processing path, contrary to the pinned type-dispatch policy.
Model: gpt-6.1-terra / max
Session: 01a22b07-00b6-7e32-b0a1-3099d0b867c7 · slot 1 · generation 39
- P2
pkg/sql/jsonvalue/value.go:99: An accounted JSON_ARRAYAGG or JSON_OBJECTAGG processes non-NULL BINARY, VARBINARY, or BLOB values.
Impact: Although the MySQL subtype is fixed for the input vector, its decimal tag width is selected repeatedly while sizing and appending individual rows. This violates the repository rule requiring type- and constant-argument decisions to occur before vector loops; no end-to-end performance regression has been measured.
Evidence: The per-row Size and Append closures call MySQLOpaqueValueSize and AppendMySQLOpaque. Both reach mysqlOpaqueFieldTypeDigits in pkg/container/bytejson/bytejson.go:506, and AppendMySQLOpaque also formats fieldType for each value. Accounted preflight and fill both execute these closures per selected row. The pinned mo-dev/references/type-dispatch.md requires these decisions outside the loop. Bind the subtype tag and its length alongside the existing vector encoder, while retaining the shared scalar encoding and exact-size accounting.
Validation:
-
Focused tests passed for bytejson, jsonvalue, aggexec and planner functions, including nullable and constant inputs and accounted two-partial merge/spill-codec cases; focused-go.log, receipt 1796135164163219736-4.json.
-
An independent wire-format oracle passed 160 subtype and payload-size combinations, including reserved-capacity and overflow checks; opaque-wire-probe.log, receipt 1796135298749018684-4.json.
-
TestTypeSwitchFamilies and git diff --check passed; receipts 1796135554925144941-4.json and 1796135600954766446-3.json.
-
The supplied CI snapshot reports successful UT, Coverage and multi-CN BVT jobs. The PR body reports current-head grouped and window SQL runs.
Limitations:
-
The local spill test exercises the spill codec; it is not a deployed physical-spill or remote partial/final acceptance run.
-
The reviewer did not independently rerun the reported SQL or race suites.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: d541a998b0d9cfc4a3d12952eabeffe25ca19a44
Assessment: request_changes
The change reuses the existing tagged JSON representation and aggregate state machinery. Batch filling now binds opaque subtype information before its loop, but window execution still rebuilds that binding for each row, leaving the prior dispatch concern open on that path.
Model: gpt-6.1-terra / max
Session: 01a22b07-00b6-7e32-b0a1-3099d0b867c7 · slot 1 · generation 39
- P2
pkg/sql/colexec/aggexec/jsonagg2.go:811: A window JSON_ARRAYAGG or JSON_OBJECTAGG processes BIT, BINARY, VARBINARY, or BLOB values.
Impact: Each frame-row fill repeats subtype selection and tag construction; BIT also repeats its width and mask decisions. This violates the pinned type-dispatch rule requiring those decisions before vector loops and adds per-row allocation work. No incorrect result or end-to-end SQL slowdown was demonstrated.
Evidence: The window loops at pkg/sql/colexec/window/window.go:767 and :1191 call Fill for individual rows. Fill delegates to a one-row BatchFill, which reaches this encoder binding on every call; the object path does the same at jsonagg2.go:853. In an internal control, 64 identical VARBINARY encodes allocated 128 times when rebinding per row versus 2 times when binding once (opaque-wire-probe.log). Bind the encoder across the input-vector processing scope or use the existing batch-fill path where appropriate, preserving vector lifetime, accounting, null handling, and cancellation.
Validation:
-
Private runtime preflight passed. Focused bytejson, jsonvalue, aggexec, and planner-function tests passed on the assigned head, including accounted partial merge and spill-codec tests; focused-go.log and checks/1796150495206176375-4.json.
-
An independent wire-format oracle passed 190 subtype and payload-size cases, and the internal binding-allocation control passed; opaque-wire-probe.log and checks/1796150571892297013-4.json.
-
The type-family guard, git diff --check, and textual merge-tree check passed. The current-head native inputs and retained library hashes were verified.
-
The frozen CI snapshot reports successful x86 unit, ARM static-analysis, and proxy and pessimistic multi-CN BVT jobs. All 81 discussion keys are recorded in discussion-assessment.json.
Limitations:
-
The allocation control isolates encoder binding; it is not an end-to-end window-query benchmark.
-
The reviewer did not run deployed same-binary remote partial/final or physical-spill acceptance. The local spill checks exercise the codec and aggregate states.
-
The latest target-branch merged binary was not independently built or executed; the supplied upgrade CI jobs were skipped.
…28947-spill-row-index
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: b07a7a587165f95bb54c090195b2f35dc36a0695
Assessment: approve
The change reuses the existing opaque JSON representation and aggregate lifecycle. The prior type-dispatch findings are addressed, and the historical mixed-version gate concerns are superseded by the pinned shutdown-upgrade policy. No actionable findings remain.
Model: gpt-6.1-terra / max
Session: 01a2350e-851d-7031-94fc-615272373c71 · slot 2 · generation 20
Validation:
-
Focused encoding, aggregate, spill-codec, window and planner tests passed, along with a race-instrumented allocation regression test.
-
An independent wire-format probe matched the merge-base encoding across subtype and payload-length boundaries.
-
Embedded single-CN SQL probes passed for grouped and window aggregates, views, CTAS and prepared-parameter rebinding.
-
The frozen CI snapshot reports successful unit, static-analysis and multi-CN BVT jobs. Receipts and retained logs are reconciled in attempt-1/validation-reconciliation.json.
Limitations:
-
The full author-reported mo-tester suites were not independently rerun. Deployed same-binary remote partial/final and physical-spill acceptance remains pending.
-
The local spill checks exercise aggregate state and the spill codec; they do not demonstrate a deployed physical spill.
What type of PR is this?
Which issue(s) this PR fixes:
issue #28891
What this PR does / why we need it:
JSON_ARRAYAGGandJSON_OBJECTAGGpreserve the MySQL opaque subtype and original bytes for BIT, BINARY, VARBINARY, and BLOB values across ordinary, window, partial/final, and spill execution. The accounted encoder preflights the exact output size and appends directly to its destination. Existing NULL and object-key rules remain covered.This candidate integrates main through
89cb66148d1c53ee2e4686b8cc8af52c7e7b7fca, including the landed CRC32 JSON change (#28935) and low-precision JSON aggregate widening. It follows the current shutdown-upgrade contract (#31287, #32926). Opaque aggregates use the existing tagged JSON encoding. The previous draft's feature-specific protocol allocation, worker probes and fallback were removed. Main's protocol generation and existing scalar admission behavior are unchanged.QA required: yes. The deployed same-binary remote partial/final and spill paths still need deployment acceptance. The previous mixed-binary experiments below record historical evidence.
Allocation regression fix at
b07a7a587165f95bb54c090195b2f35dc36a0695TestJSONAggregateOpaqueMarshalerAllocatesOncerequires one. The encoder now allocates the final output buffer directly when the destination is nil.bytejson,jsonvalue, andaggexecpackage suites passed with race instrumentation after the change. The affected packages compiled on the merge tree against85c458ac7b94d7f512087a93ff476e2a9486b49f, and the same allocation test passed there.Rebase validation at
7544854ff7e354cf111ee8cd8f7dbfce278e5e765b42e69ad5b608ca099aad87bdb8b7f78a58d73a. The 21 non-merge patches match ingit range-diff, and the rebased source tree matches the independently reviewed merge tree byte for byte.func_json_agg.test(145/145) andmysql_compat_window_json_arrayagg.sql(31/31), with zero ignored or abnormal statements. The service exited.Validation at
37d0335f70984b26793e5f5d65b0e70c2c70f472JSON_OBJECTAGG(DISTINCT ...)keeps the first occurrence of each opaque key/value pair across partial merges and spill round trips before selecting the last distinct value for each key.INTERVALpreserves finalized opaque aggregates.SLIDINGandGAPFILLreject opaque inputs at binding with error 20105.5b42e69ad5b608ca099aad87bdb8b7f78a58d73a. Local relevant package tests passed.test/distributed/cases/function/func_json_agg.test(145/145) andtest/distributed/cases/window/mysql_compat_window_json_arrayagg.sql(31/31), with zero ignored or abnormal statements. The service exited.Historical validation for
8cf074961c7ea9fc45b0ba06232a4dcad81d6e37:bytejson,jsonvalue,aggexec,window, and plannerfunctionpackages, plus focused race tests, the type-switch guard, and vet. An isolated 64-row accounted fill control produced identical bytes for BIT and VARBINARY. Allocation counts changed from 341 to 26 for array aggregation and from 406 to 91 for object aggregation.func_json_agg.test(137/137) andmysql_compat_window_json_arrayagg.sql(31/31). The new bounded-frame case asserts removal of the outgoing row, NULL, and empty binary values. Both cases recorded zero failures, skips, or abnormal statements. The service exited.f9d52a3a39edb57f33723ed8979084d0f60eda43. Formatting and diff checks passed. GitHub CI and reviewer disposition are pending for this commit. Same-binary deployed remote partial/final and physical-spill acceptance remain with QA.Historical validation for
d541a998b0d9cfc4a3d12952eabeffe25ca19a44:bytejson,jsonvalue,aggexecand plannerfunctiontests, the type-switch guard, focused race tests for the three encoding/execution packages, and vet. Tests covered exact sizes across uvarint boundaries, reuse of preallocated capacity, nullable and constant vectors, and accounted partial merge/spill codec round trips.32ffdd4ac2722972be184af63906c8f23901e323. Formatting andgit diff --checkpassed.Historical validation for
a657c253e99599e7215b04336e8d0db3759d514f:jsonvalue,aggexec, andbytejsonpackages passed their unit and focused race tests. The type-family check,go vet, and compilation of the affected packages on the merge tree againstcb2309da97c39c22c9f99298d15264f242792bbapassed.test/distributed/cases/function/func_json_agg.test(137/137) andtest/distributed/cases/window/mysql_compat_window_json_arrayagg.sql(30/30), with zero failures, skips, or abnormal statements. Service exit was verified independently after the tester's shutdown confirmation timed out.Historical validation for
06ab5f47a9f847a75cce3333adff2dfedfd444f8:bytejson,jsonvalue, andaggexec. Local vet, the type-dispatch guard, and compilation of the affected packages on the merge tree against15fb4995fa6884f8706fe8cb95beee60c5091377passed. The new constant BIT assertion fails when masking is removed.test/distributed/cases/function/func_json_agg.test(137/137) andtest/distributed/cases/window/mysql_compat_window_json_arrayagg.sql(30/30). Both cases recorded zero failed, ignored, and abnormal statements. The service stopped after the run.Historical validation for
fcc2c89d3ac430c1e27cfd527152c8145acde185:bytejson,jsonvalue,aggexec, and plannerfunctionpackages passed locally.test/distributed/cases/function/func_json_agg.test(137/137) andtest/distributed/cases/window/mysql_compat_window_json_arrayagg.sql(30/30). Each case recorded zero failed, ignored, or abnormal statements. The service stopped after the run.Historical validation for
112de28d2ece4b8c613cd9cc6fa1589658796c2d:mo-cgo-test -json -p 4 -race -count=1 -timeout=8macrosspkg/container/bytejson,pkg/sql/jsonvalue,pkg/sql/colexec/aggexec, andpkg/sql/plan/functionon Go 1.27.1 (Darwin arm64). All four packages passed, with 19,955 passing tests and subtests. The selection includes the opaque bytes, typed spill round trip, low-precision planner widening, scalar v52 admission and CRC32 legacy-identity tests.go vet,gofmt -landgit diff --check. The independent shutdown-contract review covered the same production source.make build-with-prebuilt-native, passedtest/distributed/cases/function/func_json_agg.test(137/137) andtest/distributed/cases/window/mysql_compat_window_json_arrayagg.sql(30/30). The isolated single-CN runner used the CInometaandignoreoptions. Zero statements failed, were ignored or were abnormal. The service exited after the run.Historical semantic maintenance validation at 4638895 — 2026-10-08
4638895833f84b4049a779ba9379c97916de35e3; first maintenance head:bebb18160dd2ad00be69250abac212ee2a296927; original source:8c246188fcf7573c394ae56e6b604b02ef129f7d; latest normal-merged actual main:dce60631f8c857ae730a4d2f328df5962e4f2a8d. No history rewrite.fcba09be73(2026-10-29):pkg/sql/colexec/aggexecJSON suites 33/33 PASS;pkg/sql/compileOpaque suites 6/6 PASS plus 203 Placement/Schedule/Protocol adjacent suites PASS;pkg/pb/planOpaque 4/4 PASS; build embedded CommitID=fcba09be73.test/distributed/cases/function/func_json_agg.test137/137 twice andtest/distributed/cases/window/mysql_compat_window_json_arrayagg.sql30/30 twice, zero failed/ignored/abnormal.Historical validation at the previous v101 source
The following 2026-09-29 receipts are preserved as historical evidence for the exact old/new builds stated below. They do not certify the current proposed-v107 candidate or today's base. Current old/new executable, replacement-window and rolling-upgrade acceptance is NOT_RUN until those receipts are refreshed against the current version/content.
8c246188fcf7573c394ae56e6b604b02ef129f7d(MORPC v101); independently built old source:466eb8ff4f65752ad25d7e19274770459f5ef934(MORPC v100). The frozen O build is the stated predecessor, not a build from the current main. Main has since advanced to9e50a0f2c925c512fe13f54611630aa615ac93db; any candidate or base change requires new verification.git diff --check: PASS. Canonical grouped (117 statements) and window (22 statements) BVT each passed twice on the same isolated instance with cleanup.pr28947-20260929-4bbff25cbuilt O and N independently with separate native dependencies. Binary SHA-256: Ob50e471bd9754d9b49b0b8ef149103ab3045b2f89128c1ff88f13fe88d858ff4, N95cce206bf1275c629e3178077c0dcf7b4d29d072d22844e68dffa63e851dee4. Source and native provenance, toolchain, wrapper and case receipts are in the run manifest.SUMactually ran a remote worker and returned the exact result; old-entry opaque binary aggregate was explicitly rejected. A separate old-entry BIT(7) aggregate returned error 20301 (unsupported type for json aggregate: BIT), followed by a healthy query on the same connection. N coordinator → O worker: opaque aggregate ran only on N with exact subtype and00ffpayload, while O was excluded. This observed exclusion is not direct evidence that the v101 capability probe rejected O:DiscoverQueryCandidatesfirst filters out a differentCommitID. The in-process QueryService test separately checks the capability gate. N coordinator → N worker: remote scan/partial and coordinator merge/final ran, with exact opaque bytes and healthy same-instance follow-up. Physical spill wrote 44,250,840 bytes at a 1 MiB threshold, then preserved BIT/BINARY/VARBINARY/BLOB subtype, payload, NULL/empty/NUL/0xff, DISTINCT and object semantics. All 27 case attempts ended with owned-process and port cleanup.GetProtocolVersionRPC from the N probe to the actual O worker returned v100, while the N coordinator returned v101 (real-queryservice-NO.json). Thus the old executable's reported capability is below the v101 gate; this still does not prove that production placement or sender validation reached O.DiscoverQueryCandidatescurrently requires equalCommitID, excluding the independently built N worker. This direction is INCONCLUSIVE, not a remote-interoperability PASS.CommitID; it does not claim SQL scheduling or receiver coverage.CommitIDfence.binary data not supported json aggregate: VARBINARY) in 6.933 seconds, corroborated twice in the O worker log. A subsequent healthy query and exact-owned cleanup passed. This proves the actual old executor did not silently return wrong bytes at this hit window. The prior v14/v15 attempts wereINCONCLUSIVEbecause the plan omitted addresses or the pipeline connection was reused.Historical CR, CI and QA status at v101
8c246188fcf7573c394ae56e6b604b02ef129f7d; 14 checks, including Upgrade compatibility, are SKIPPED, and two are neutral. Deployed QA: NOT_RUN. Local tests, mo-55 experiments, CI and QA are separate evidence layers.JSON_ARRAYAGG(DISTINCT ...)behavior preserves repeated SQL NULLs; this is recorded as observed behavior, not a new contract change.Historical SCA follow-up at 9e55edd
Removed the unused private
buildValueByteJsonandbuildJSONArrayValueByteJsonwrappers. Repository-wide reference inspection finds no callers; all live production/tests already use the protocol/location-aware functions, which are unchanged. This repairs the exact-head unused-analyzer failure in run37733868609/job113169385413 without lint suppression or semantic changes. Local Go1.27.0/golangci-lint2.14.0 configured full aggexec-package scan passes (zero issues). Controlled complete aggexec package passes 2,389 tests/subtests plus package result, no failures; diff-check passes. Prior semantic/race/BVT receipts above retain their original SHA and are reused for unchanged executable behavior, not reported as freshly rerun SQL. New-head full CI is pending. All current remaining compatibility/allocation/deployment gates above remain open; no review thread was resolved or reviewer automatically requested. Ready is preserved.