Skip to content

fix(json): accept numeric keys in json_objectagg - #28331

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/28032-json-objectagg-numeric-keys
Sep 15, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/28032-json-objectagg-numeric-keys

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 7, 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 #28032

What this PR does / why we need it:

JSON_OBJECTAGG now admits conventional numeric key expressions (signed and unsigned integers, FLOAT, DOUBLE, and DECIMAL) through the existing implicit VARCHAR cast path. The executor still receives string keys, so numeric member-name formatting follows the existing explicit CAST(... AS CHAR) oracle. BIT is explicitly excluded even though Type.IsNumeric() includes it.

Existing string and binary-string key behavior, binary value rejection, NULL-key runtime errors, NULL values, empty input, duplicate-key behavior, and aggregate/window state handling remain unchanged. No protocol, state, or framework changes are included.

Changed files:

  • pkg/sql/plan/function/list_agg.go
  • pkg/sql/plan/function/list_agg_test.go
  • test/distributed/cases/function/func_json_agg.test
  • test/distributed/cases/function/func_json_agg.result
  • test/distributed/cases/window/mysql_compat_window_json_arrayagg.sql
  • test/distributed/cases/window/mysql_compat_window_json_arrayagg.result

Dependencies and merge order:

Publication snapshot:

  • Target main: 23c8cb676edd4fecd2127ec311b540a5a34211e0
  • PR head: d6bb9fc7617d28306a11a7c23e402efed8f5626a
  • State: OPEN, ready for maintainer review (Ready does not claim CI, merge, or QA completion)

Validation status:

  • PASS — focused resolver tests: GOWORK=off go test -mod=readonly -v -count=1 -timeout 120s -run '^TestJSONObjectAgg(NumericKeyResolution|KeyTypeBoundaries)$' ./pkg/sql/plan/function
  • PASS (non-native Go path only) — GOWORK=off go test -mod=readonly -count=1 -timeout 120s ./pkg/sql/plan/function; the required CGo wrapper gate is reported separately below.
  • PASS — owning package build and vet: GOWORK=off go build -mod=readonly ./pkg/sql/plan/function; GOWORK=off go vet -mod=readonly ./pkg/sql/plan/function
  • PASS — supporting aggregate consumer tests on the normal Go path, covering accounting, spill/restore, key/value errors, merge, and cleanup paths.
  • PASS — MySQL parser syntax probe for the added scalar, NULL-value, GROUP BY/ORDER BY/LIMIT, and prepared statements.
  • FAIL (baseline reproducer) — target-base resolver rejects conventional numeric key types before this change; this is the issue behavior and is not a post-fix failure.
  • BLOCKED_ENVIRONMENT — MatrixOne CGo wrapper tests could not start because this checkout and the primary worktree lack cgo/libmo.dylib and thirdparties/install; no CGo test result is claimed.
  • BLOCKED_ENVIRONMENT — the focused window consumer package also stopped before test selection on missing docfilter CGo symbols; its MatrixOne CGo wrapper is blocked by the same native prerequisite.
  • BLOCKED_ENVIRONMENT — canonical function and window BVTs could not start because the host has no Java Runtime; no BVT PASS is claimed.
  • NOT_RUN — exact-head native CGo and BVT execution remain pending the required native artifacts and Java runtime.
  • RUNNING — exact-head GitHub Actions run 34913627312 has started; UT, SCA, shared build, and coverage jobs are still pending at this snapshot.
  • INCONCLUSIVE — checks from the superseded pre-push head included runner-derived failures/pending jobs; they are not treated as evidence for d6bb9fc7617d28306a11a7c23e402efed8f5626a.
  • git diff --check: PASS.

Final-head joint pre-review:

  • PASS — Astra independently ran mo-self-review and mo-pr-preflight-review over the complete six-file diff at head d6bb9fc7617d28306a11a7c23e402efed8f5626a; no unresolved blocking finding remains.
  • Review artifact: /Users/violet/Documents/Codex/artifacts/matrixone-pr-pipeline/pr28331-astra-d6bb9fc/review.md; validator: PASS semantic=PASS.
  • Review merge-base/base snapshot: 23c8cb676edd4fecd2127ec311b540a5a34211e0; current main observed before Ready: f0f61f0bc6852a67447921733f641c7d32c0c25b.
  • NOT_RUN / BLOCKED_ENVIRONMENT — native CGo, canonical BVT, MySQL comparison, and formal QA remain pending because required native artifacts/Java are unavailable. These gaps are disclosed and are not represented as PASS.
  • Non-blocking follow-ups: strengthen exact singleton duplicate-key assertion and add native numeric prepared-packet plus failed-execution recovery coverage.

QA required: yes. QA should compare against MySQL 8 across scalar, grouped, window/OVER, ORDER BY/LIMIT, prepared and repeated execution, explicit-cast equivalence, NULL key/value and empty input, rejected BIT/BOOL/ENUM/temporal/JSON/UUID types, binary key/value boundaries, duplicate keys, and single-CN/multi-CN aggregate accounting, partial merge, spill, error, and cleanup paths.

Self-review (mo-self-review):

  • Findings: no merge-blocking correctness, compatibility, lifecycle, concurrency, or performance finding remains after a full diff sweep.
  • Functional closure: resolver admission produces the existing implicit VARCHAR cast; the unchanged executor continues to consume string keys. Existing aggregate consumer tests cover accounting, partial merge, spill/restore, error, cleanup, and empty-result behavior; existing window tests cover NULL-key error cleanup and Reset.
  • Counterexample challenges: BIT is confirmed numeric but is rejected by the explicit OID guard; BOOL, ENUM, temporal, JSON, and UUID remain rejected; binary keys retain the existing string path; binary values remain rejected; NULL key, NULL value, duplicate ordering, prepared reuse, failure recovery, and empty input have explicit checks.
  • Decision log: no executor, protocol, state, framework, or race-sensitive code changed, so no race stress gate is triggered. Remaining gaps are environment-gated CGo/BVT execution, pending exact-head CI, and required QA comparison.

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

Reviewed all six changed files. No blocking finding in the scoped numeric-key admission change.

Conventional numeric keys are converted through the existing VARCHAR cast, while the executor, aggregate state and duplicate-key policy remain unchanged. The resolver tests cover signed/unsigned widths, float/decimal domains, retained string types and explicitly excluded special types. The ordinary duplicate test no longer assumes an unordered aggregate's input order; the explicit ROWS-frame window case owns the deterministic last-wins assertion. NULL-key error, prepared explicit/bare casts and grouped controls are included.

This is a code-review approval at this SHA, not permission to bypass the declared Draft hold. #28094 must land, shared aggregate BVT additions must be reconciled, and the resulting head needs current native/mo-tester and QA evidence. Prior unchanged-production resolver/package evidence is reused; I did not run new native tests and do not count the JDK/CGo-blocked attempts as passes. Keep #28032 open through versioned QA.

mergify Bot pushed a commit that referenced this pull request Sep 14, 2026
After #28093 merged, this PR is rebased onto the current `main` and contains only the independent JSON_ARRAYAGG delta. It routes TIME, DATETIME, and YEAR inputs through the shared typed conversion: TIME and DATETIME retain their ByteJson kinds with six fractional digits, YEAR is numeric with public JSON type `INTEGER`, and DISTINCT continues to hash the original SQL vector.

Regular construction, allocation preflight, accounted append, merge, and spill reload use the same atom representation and encoded size. Coverage includes regular/accounted equality, state-free preflight, one-byte-short allocation failure, partial merge, spill save/reload, NULL, DISTINCT, and prepared YEAR.

Dependency and merge order:

- #28092 and #28093 are merged prerequisites. The cumulative constructor/member-of commits were removed; the remaining history is two ARRAYAGG commits.
- Current clean head is based on `main@b7eca64` and is ready for fresh review. The PR is Ready for maintainer review; QA remains a separate acceptance gate.
- #28331 (issue #28032) is the next JSON aggregation follow-up and shares `func_json_agg.test/result`; it must wait for this PR, then rebase and replay its numeric-key additions.

QA required: yes — issue #28061 remains open until exact-version, MySQL comparison, and topology tester evidence completes.

Production terminal covered by automation: JSON_ARRAYAGG TIME/DATETIME/YEAR, NULL, DISTINCT, prepared YEAR, regular/accounted/preflight, merge, spill, and allocation failure.

Remaining QA: exact MySQL 8 comparison, single/multi-CN, timezone and persisted-read scenarios; TIMESTAMP timezone and binary/BIT/geometry ARRAYAGG admission remain explicit follow-up scope.

Validation at exact local head `aed3f36ba927b46b10485ce1a45c448ca5ac76ec` (base `b7eca642ce9b6a4c2ebeca3be378d016d19ff9c1`):

- `GOWORK=off go list/build/vet -mod=readonly ./pkg/sql/colexec/aggexec`: PASS
- Focused `mo-cgo-test` ARRAYAGG set (6 tests): PASS
- Full `mo-cgo-test -count=1 ./pkg/sql/colexec/aggexec`: PASS
- Semantic preflight schema v7: `PASS semantic=PASS`, diff `8277dd6ce07a3fbfb69034e19817bceccf1946a7a6642e6d88372b676d8d0f9b`
- Canonical BVT `test/distributed/cases/function/func_json_agg.test/result`: retained; local execution is pending because this host has no Java runtime. CI/QA remains the acceptance gate.
- `git diff --check`: PASS

Approved by: @XuPeng-SH
@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

I repaired the BVT artifact mismatch at the exact PR head 4584adff21f4dc6741bb397fd893e0a4de5a4894 (base main@2ea4ec2e6ef4b20321a235ef416228506813e39b). The mo-tester parser trims each .test line before matching it against .result; the t_obj_numeric DDL block in func_json_agg.result retained indentation, so the parser rejected command 30 before executing the script. The result block now uses the parser's normalized command text. Local byte-level matching passes for all 96 commands and git diff --check passes.

The previous run 34921979000 / BVT job 104233784365 also reported coverage as a derived producer-incomplete failure; it did not establish a product runtime verdict. Please review the new exact head and let the fresh BVT/coverage workflow complete.

@mergify

mergify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-15 06:33 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-15 06:34 UTC · at ceaf9c6f88ab184d4e1684d413bfe40ae4b56a44 · squash

This pull request spent 21 seconds in the queue, including 1 second running CI.

Required conditions to merge

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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants