Skip to content

[Compatibility]: preserve opaque values in JSON aggregates - #28947

Open
VioletQwQ-0 wants to merge 33 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28891-json-opaque-agg-20260916
Open

VioletQwQ-0 wants to merge 33 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28891-json-opaque-agg-20260916

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #28891

What this PR does / why we need it:

JSON_ARRAYAGG and JSON_OBJECTAGG preserve 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 b07a7a587165f95bb54c090195b2f35dc36a0695

  • The Ubuntu x86 race run observed two allocations where TestJSONAggregateOpaqueMarshalerAllocatesOnce requires one. The encoder now allocates the final output buffer directly when the destination is nil.
  • Ubuntu x86 with Go 1.27.1 reproduced the failure before the change. The original assertion and the bytejson, jsonvalue, and aggexec package suites passed with race instrumentation after the change. The affected packages compiled on the merge tree against 85c458ac7b94d7f512087a93ff476e2a9486b49f, and the same allocation test passed there.
  • The grouped and window BVT runs below are evidence for the previous commit. GitHub CI and reviewer disposition are pending for this update.

Rebase validation at 7544854ff7e354cf111ee8cd8f7dbfce278e5e76

  • Rebased onto 5b42e69ad5b608ca099aad87bdb8b7f78a58d73a. The 21 non-merge patches match in git range-diff, and the rebased source tree matches the independently reviewed merge tree byte for byte.
  • Relevant package selections passed. The planner and planner-function results are reused from the independently tested, identical merge tree.
  • The rebased single-CN binary passed func_json_agg.test (145/145) and mysql_compat_window_json_arrayagg.sql (31/31), with zero ignored or abnormal statements. The service exited.

Validation at 37d0335f70984b26793e5f5d65b0e70c2c70f472

  • Ordinary JSON aggregation reuses the encoded opaque bytes. A regression test observes one allocation, and restoring the redundant Marshal round trip makes it observe two.
  • Accounted JSON_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.
  • Ordinary INTERVAL preserves finalized opaque aggregates. SLIDING and GAPFILL reject opaque inputs at binding with error 20105.
  • Independent Astra High deep review passed on this commit. Seven related Go packages compiled on the merge tree against 5b42e69ad5b608ca099aad87bdb8b7f78a58d73a. Local relevant package tests passed.
  • An exact-commit single-CN binary passed test/distributed/cases/function/func_json_agg.test (145/145) and test/distributed/cases/window/mysql_compat_window_json_arrayagg.sql (31/31), with zero ignored or abnormal statements. The service exited.
  • GitHub checks and reviewer sign-off are pending. Deployed same-binary multi-CN partial/final and physical-spill acceptance remain with QA.

Historical validation for 8cf074961c7ea9fc45b0ba06232a4dcad81d6e37:

  • Addresses the window row binding review. The window evaluator binds the JSON aggregate row filler once per output range. Grouped batches and window frames share the filler, with byte format, NULL semantics, row order, memory accounting, and cancellation covered by the existing execution paths.
  • Ubuntu passed the full bytejson, jsonvalue, aggexec, window, and planner function packages, 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.
  • A single-CN Ubuntu service built from this commit passed func_json_agg.test (137/137) and mysql_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.
  • The affected packages compiled on the merge tree against 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:

  • Addresses the opaque tag dispatch review. The vector encoder binds the MySQL subtype tag once for BIT, BINARY, VARBINARY and BLOB. Scalar and aggregate encoding share the checked envelope layout and write the same bytes.
  • Ubuntu passed the focused bytejson, jsonvalue, aggexec and planner function tests, 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.
  • The affected packages compiled on the merge tree against 32ffdd4ac2722972be184af63906c8f23901e323. Formatting and git diff --check passed.
  • Canonical grouped and window SQL cases are included in the PR. This head awaits GitHub CI, reviewer disposition, and deployed same-binary remote partial/final and physical-spill acceptance.

Historical validation for a657c253e99599e7215b04336e8d0db3759d514f:

  • Addresses the general type switch review. The three opaque arms and their unused scalar wrappers were removed. The vector-bound encoder remains the aggregate entry point, and the tests now exercise it directly.
  • On Ubuntu, the jsonvalue, aggexec, and bytejson packages passed their unit and focused race tests. The type-family check, go vet, and compilation of the affected packages on the merge tree against cb2309da97c39c22c9f99298d15264f242792bba passed.
  • The Ubuntu single-CN binary built from this commit passed test/distributed/cases/function/func_json_agg.test (137/137) and test/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.
  • GitHub CI, reviewer disposition of the historical threads, and deployed same-binary remote partial/final and physical-spill acceptance remain pending.

Historical validation for 06ab5f47a9f847a75cce3333adff2dfedfd444f8:

  • Addresses the batch dispatch review. The encoder selects the MySQL opaque subtype, BIT byte width and mask once per value vector in allocation preflight and fill. The same byte format and exact sizing contract apply to NULL, flat, and constant inputs.
  • Local package tests and focused race tests passed for bytejson, jsonvalue, and aggexec. Local vet, the type-dispatch guard, and compilation of the affected packages on the merge tree against 15fb4995fa6884f8706fe8cb95beee60c5091377 passed. The new constant BIT assertion fails when masking is removed.
  • The single-CN binary built from this commit passed test/distributed/cases/function/func_json_agg.test (137/137) and test/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.
  • GitHub CI, reviewer disposition of the historical threads, and deployed same-binary remote partial/final and physical-spill acceptance remain pending.

Historical validation for fcc2c89d3ac430c1e27cfd527152c8145acde185:

  • The two accounted spill test cases now pass 64-bit row indexes to the current spill API. The targeted aggregate tests and the bytejson, jsonvalue, aggexec, and planner function packages passed locally.
  • The local single-CN binary reporting this commit passed test/distributed/cases/function/func_json_agg.test (137/137) and test/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.
  • GitHub CI tracks this commit. Deployed same-binary remote partial/final and physical spill still require QA. The historical review threads remain open for reviewer follow-up.

Historical validation for 112de28d2ece4b8c613cd9cc6fa1589658796c2d:

  • PASS: mo-cgo-test -json -p 4 -race -count=1 -timeout=8m across pkg/container/bytejson, pkg/sql/jsonvalue, pkg/sql/colexec/aggexec, and pkg/sql/plan/function on 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.
  • PASS: incremental go vet, gofmt -l and git diff --check. The independent shutdown-contract review covered the same production source.
  • PASS: the exact clean candidate binary, built with make build-with-prebuilt-native, passed test/distributed/cases/function/func_json_agg.test (137/137) and test/distributed/cases/window/mysql_compat_window_json_arrayagg.sql (30/30). The isolated single-CN runner used the CI nometa and ignore options. Zero statements failed, were ignored or were abnormal. The service exited after the run.
  • The issue records the original affected deployment rejecting these aggregate inputs. This run used the synchronized candidate binary.
  • GitHub CI and deployed QA are pending. The existing historical review threads remain open for maintainer follow-up under the documented shutdown-upgrade contract.

Historical semantic maintenance validation at 4638895 — 2026-10-08

  • Candidate: 4638895833f84b4049a779ba9379c97916de35e3; first maintenance head: bebb18160dd2ad00be69250abac212ee2a296927; original source: 8c246188fcf7573c394ae56e6b604b02ef129f7d; latest normal-merged actual main: dce60631f8c857ae730a4d2f328df5962e4f2a8d. No history rewrite.
  • The PR API's base SHA was an older snapshot. A fresh main-branch ref/remote check found three new commits and an actual two-file conflict: main's TIMESTAMP/session-zone window BVT and this PR's opaque window BVT both appended at the same location. Both blocks and their original expected results are retained; no expectations weakened.
  • Preserves main's v107-v134 entries and behavior. New aggregate capability v137 rejects actual predecessor v134; lowered aggregate instructions and destination probes are checked independently of scalar opaque v52; the required send gate retains probe causes while the optional worker constraint keeps single-CN fallback through the ForPlacement probe variant. Main's CommitID candidate fence remains unchanged.
  • Opaque encoding uses checked exact size and direct append; accounted/unaccounted aggregate initialization, merge, spill, arena preflight and executor reuse carry the capability. Unsupported and NULL/key/value categories retain separate contracts.
  • PASS: owning fresh native generation/service build, Darwin/arm64, direct Go1.27.0. Nine owning package groups (ByteJSON, protobuf plan, shared jsonvalue, aggexec, group, timewin, window, function, compile): 17,211 PASS records (including package results). The initial command used a nonexistent jsonvalue package path; all eight valid packages passed, and the corrected shared-jsonvalue package passed separately (22 tests). The command setup error is not reported as a product PASS.
  • PASS: focused aggregate lifecycle/account/preflight/merge/spill race selection, 30 PASS records, no race. PASS: canonical grouped BVT 137/137 and window BVT 22/22, each twice on the freshly built owned single-CN service; zero failed, ignored or abnormal statements, byte-identical case/result staging. Native wrapper is from this owning checkout, not the primary worktree.
  • Re-validated on head fcba09be73 (2026-10-29): pkg/sql/colexec/aggexec JSON suites 33/33 PASS; pkg/sql/compile Opaque suites 6/6 PASS plus 203 Placement/Schedule/Protocol adjacent suites PASS; pkg/pb/plan Opaque 4/4 PASS; build embedded CommitID=fcba09be73.
  • BVT on the code-identical predecessor binary (delta is a comment-only commit): test/distributed/cases/function/func_json_agg.test 137/137 twice and test/distributed/cases/window/mysql_compat_window_json_arrayagg.sql 30/30 twice, zero failed/ignored/abnormal.
  • Earlier-era receipts (v101 pairwise runs, client-GC suites and historical windows) remain useful as mechanism history only; they are not bound to today's head. Old/new executable, replacement-window and rolling-upgrade acceptance stays NOT_RUN on the current head.
  • PASS: independent full 28-file change map, semantic/lifecycle preflight, self-review, formatting and main-to-candidate diff-check. Owned service was stopped after repeat execution; data, raw evidence and reports are retained.
  • New-head CI remains separate and is freshly checked after publication. No automatic resolve, reviewer request, issue closure or deployed-QA claim.

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.

  • Candidate source: 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 to 9e50a0f2c925c512fe13f54611630aa615ac93db; any candidate or base change requires new verification.
  • Local official build, focused protocol and accounted two-partial merge/spill tests, seven affected package groups, incremental lint (zero issues), and git diff --check: PASS. Canonical grouped (117 statements) and window (22 statements) BVT each passed twice on the same isolated instance with cleanup.
  • mo-55 run pr28947-20260929-4bbff25c built O and N independently with separate native dependencies. Binary SHA-256: O b50e471bd9754d9b49b0b8ef149103ab3045b2f89128c1ff88f13fe88d858ff4, N 95cce206bf1275c629e3178077c0dcf7b4d29d072d22844e68dffa63e851dee4. Source and native provenance, toolchain, wrapper and case receipts are in the run manifest.
  • O coordinator → O worker: ordinary 5-million-row grouped SUM actually 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 and 00ff payload, while O was excluded. This observed exclusion is not direct evidence that the v101 capability probe rejected O: DiscoverQueryCandidates first filters out a different CommitID. 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.
  • A direct QueryService GetProtocolVersion RPC 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.
  • O coordinator → N worker: old-entry opaque aggregate rejection passed, but the ordinary aggregate did not reach N. DiscoverQueryCandidates currently requires equal CommitID, excluding the independently built N worker. This direction is INCONCLUSIVE, not a remote-interoperability PASS.
  • Actual old QueryService gate: an evidence-only Go overlay in the unchanged N checkout called the production worker-admission, sender-destination and fallback functions through an SSH tunnel to the independently built O worker. O was rejected for v101, fallback selected one CN, and cancellation propagated. The test supplies selected-node metadata because the normal SQL candidate pool filters differing CommitID; it does not claim SQL scheduling or receiver coverage.
  • Pre-send replacement: that same production sender function first admitted a real N worker, then the exact worker process changed to real O using the same UUID/config/address. Sender re-probing rejected O, one-CN fallback and the next SQL query passed, and cleanup passed. Selected-node metadata was supplied by the test; ordinary cross-build SQL placement is still blocked by the CommitID fence.
  • Post-probe/pre-pipeline replacement: a direct probe verified N QueryService v101; after arming, the byte-transparent relay observed two QueryService response chunks and held pipeline bytes. The independently built N worker was stopped and replaced by O with the same UUID, config and advertised address; the O QueryService returned v100. Releasing the original bytes produced a bounded SQL error (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 were INCONCLUSIVE because the plan omitted addresses or the pipeline connection was reused.
  • Different-ID replacement: the same pipeline barrier was hit with O restarted at the same advertised address but a new UUID. The original bytes reached the actual O executor, whose log recorded VARBINARY rejection twice; SQL failed explicitly in 5.416 seconds, the next query passed, and owned cleanup passed.
  • Probe failure and placement policy: after a real O response, the exact old worker was stopped. Production functions on N rejected the destination, fell back to one CN when local placement was allowed, returned a clear error when excluded, and propagated cancellation in under one second. A healthy coordinator query and cleanup passed. Selected-node and placement policy were supplied by the test; a separate in-flight SQL disconnect experiment is reported below.
  • In-flight SQL disconnect: a real N→N opaque aggregate reached the worker through the byte-transparent pipeline relay. After the original bytes were forwarded, the SQL client socket was shut down; the client query ended immediately with a connection error. A new remote opaque aggregate on the same cluster returned 1024 groups with exact bytes, followed by owned cleanup. This proves bounded client termination and same-instance remote reuse; individual receiver/goroutine/account release was not directly measured.

Historical CR, CI and QA status at v101

  • The historical v94 collision and local merge/spill coverage are addressed. The two old/new-executable threads remain open for reviewer acceptance. Real old admission/sender rejection, one-CN fallback, BIT baseline, pre-send replacement, post-probe receiver replacement with same or different UUID, bounded errors, next-query reuse and exact-owned cleanup now have evidence. Ordinary cross-build SQL placement remains INCONCLUSIVE because the exact CommitID candidate fence prevents N→O and O→N remote selection. Placement policy and probe failure are covered at production-function level. In-flight SQL disconnect has bounded client termination and remote reuse evidence, but no direct per-query receiver/goroutine/account count. The independent v101 collision with fix: restore prepared TPCC filter selectivity with per-binding proof #29462 remains a separate open version-coordination blocker. The full rolling-upgrade contract is not yet proved.
  • New-head CI: 12 SUCCESS checks and no failures or pending checks at 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.
  • QA should cover grouped/window execution, all four opaque subtypes, SQL NULL, empty and binary payloads, DISTINCT, duplicate object keys, remote partial/final, physical spill and rolling-version placement. Existing JSON_ARRAYAGG(DISTINCT ...) behavior preserves repeated SQL NULLs; this is recorded as observed behavior, not a new contract change.
  • The Draft status recorded here applied to the v101 candidate.

Historical SCA follow-up at 9e55edd

Removed the unused private buildValueByteJson and buildJSONArrayValueByteJson wrappers. 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.

@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Sep 15, 2026
@VioletQwQ-0
VioletQwQ-0 force-pushed the codex/issue-28891-json-opaque-agg-20260916 branch from ec323c9 to ad0672f Compare September 15, 2026 19:18
@VioletQwQ-0
VioletQwQ-0 marked this pull request as ready for review September 15, 2026 19:31
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

@aptend @XuPeng-SH Could you re-review draft head 301596b63e0e9ab250e1295c0a0b3998ea98df1e under the current shutdown-only upgrade policy (#31287, #32926)?

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.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

🛑 Queue command cancelled

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: fcc2c89d3ac430c1e27cfd527152c8145acde185

Review completed. Read the assessment.

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

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.

@mergify

mergify Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

queue

🛑 The queue request has been cancelled: new commits were pushed

Details

@VioletQwQ-0 pushed to this pull request after queue was requested. Review the new commits and request it again.

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 06ab5f47a9f847a75cce3333adff2dfedfd444f8

Review completed. Read the assessment.

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

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.

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: a657c253e99599e7215b04336e8d0db3759d514f

Review completed. Read the assessment.

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

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.

@XuPeng-SH

XuPeng-SH commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: d541a998b0d9cfc4a3d12952eabeffe25ca19a44

Review completed. Read the assessment.

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

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.

@XuPeng-SH

XuPeng-SH commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: b07a7a587165f95bb54c090195b2f35dc36a0695

Review completed. Read the assessment.

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

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.

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants