Skip to content

feat: support JSON_ARRAY_INSERT - #29519

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28033-json-array-insert
Oct 8, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28033-json-array-insert

Conversation

@VioletQwQ-0

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

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • Feature
  • BUG

Which issue(s) this PR fixes:

issue #28033 (partial delivery; QA required)

What this PR does / why we need it:

Implements the MySQL-compatible JSON_ARRAY_INSERT increment for issue #28033. This partial increment does not close the broader issue. Ready is preserved.

Contract

Insert before simple array-index terminals, including last/last-N; append forward out-of-range indexes and clamp reverse underflow to the head. Apply pairs left-to-right; missing/non-array parents are no-ops. SQL NULL document/path returns SQL NULL; NULL values insert JSON null. Invalid terminals and existing document/path limits remain enforced. Values use the shared JSON constructor conversion, including concrete prepared binary FLOAT metadata.

2026-10-08 maintenance

  • Published candidate: 22910ec607b8cbf0ea847c7dc0d98af5749fefaf; original source: 604353a1fe7c425fd59eebc1e2b25bb1128b4d14.
  • Normal merge integrates actual main bab4b3286a0dd5683a9b291763817722233e586c. JSON_ARRAY_INSERT uses function ID 586, preserving main's already allocated IDs 584/585; registry boundary becomes 587. Recheck the registry against actual main at landing.
  • Prepared value-position discovery joins main's canonical constructor metadata path. Regressions cover concrete MYSQL_TYPE_FLOAT payload and paired path/value positions, not just textual PREPARE.
  • PASS: fresh native generation/provenance and service build on Darwin/arm64, direct Go 1.27.0.
  • PASS: complete ByteJSON, function, planner and frontend packages with the worktree controlled-CGo wrapper: 28,976 tests/subtests, zero failures.
  • PASS: canonical func_json_array_insert.sql, 22/22 statements twice on the freshly built owned single-CN service; zero failures, ignored or abnormal results. Runner b95f5c09930c42bdbe77828b6ae72d39f2be48ed / Java17.0.15; SQL/result inputs copied byte-identically, no result regeneration. Canonical DROP and repeat execution succeed.
  • PASS: focused self-review/preflight, formatting and git diff --check.

CI, review and QA

The original-head proxy/pessimistic BVT jobs failed on an unauthorized MinIO image pull before SQL execution; aggregate coverage lacked upstream artifacts. This is setup/tooling evidence, not a demonstrated JSON_ARRAY_INSERT test failure. No hourly/manual blind rerun was issued. The new head starts new CI; its result is pending.

No unresolved review thread was present at the verified original head. Historical semantic preflight and BVT receipts are not promoted to this new head; the current evidence is listed above. Deployed/mixed-version QA, current required CI, formal review and broader #28033 scope remain separate gates. No issue closure, QA handoff or merge is claimed.

2026-10-08 strict ARRAY_INSERT parent lookup follow-up

Current repair head: d31fb6c6dedbb0af83386e033a8ecd81f865ea7b; target/validation base: bab4b3286a0dd5683a9b291763817722233e586c.
The common simple-path resolver now has explicit scalar/object wrapping policy. ARRAY_INSERT alone disables both while seeking its parent; existing callers keep their prior behavior. Intermediate object [0]/[last] paths leave the document unchanged, while real-array and direct-member paths still insert. The invalid-terminal test registers immediate fixture cleanup.
Validation: complete ByteJSON and function packages passed (10,652 named test/subtest PASS events), configured owning-package lint reported 0 issues, and diff check passed. The 12-row parent/index-kind matrix and varchar/binary-JSON executor counterexamples pass. On the original source, object-zero/object-last counterexamples FAIL while object-one control PASS with matching native inputs. Canonical test/distributed/cases/function/func_json_array_insert.sql/.result passed 28/28 twice on one ready owned instance, zero failed/ignored/abnormal; service stopped. Default SIMD service build hit a Go compiler crash; repository-supported ARCHSIMD=0 build and subsequent SQL BVT passed. No SIMD validation claim is made. Fresh CI belongs to this new head and remains pending. Historical evidence above keeps its original revision.
QA required: yes — this scoped repair does not close deployment acceptance or umbrella issue #28033.

2026-10-08 CI timing-oracle follow-up

Published head: eaf150ef44f95dfab77623f252de82b1c9be5678. The previous head's PROXY BVT run 37748550739 failed the existing SYSDATE/SLEEP oracle: a valid delayed resume returned three elapsed seconds instead of the asserted exactly two. The test now checks elapsed seconds >= 2 and successful SLEEP return 0; production code, sleeps, case count and other oracles are unchanged. Source SYSDATE reads call-time wall clock, and timer expiry does not promise an exact resume deadline. This is an oracle correction, not a product latency bound or a claim that the whole CI failure is resolved.

Fresh supported CPU build PASS (Darwin arm64, Go1.27, ARCHSIMD=0). Canonical func_datetime_now.test/.result normal comparison: 50/50 PASS twice on the same ready owned service, zero failures/ignored/abnormal. Additional SQL boundary controls reject zero/one-second deltas and accept two/three; fixture table absence was verified after each run and the service stopped. Diff check and incremental self-review PASS. No unrelated Go/race/benchmark validation is claimed for this SQL-test-only change. Local single-CN evidence does not replace new-head PROXY/multi-CN required CI.

The old Coverage job reported an incomplete required producer profile and calculated no coverage verdict; it is not labeled a coverage-percentage defect. Old runs are superseded, not rerun. New-head CI and the existing requested Xu review remain separate pending gates. No associated issue closure or deployed QA acceptance is implied.

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

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

Deep re-review of exact head eaf150e, merge-base bab4b32: APPROVE. No remaining blocking finding in this scoped increment.

Both previous review findings are closed in code, not merely marked resolved: ARRAY_INSERT now requests strict scalar AND object parent lookup from the existing resolver, while every pre-existing caller preserves its old wrapping policy; the expected-error FunctionTestCase registers immediate cleanup. The original object-[0]/[last] counterexamples now pass with real-array/direct-member controls, including varchar and binary-JSON executor paths.

Reviewed all 16 changed files, separately covering production, UTs and SQL/result deltas (no design-document delta). The implementation reuses the existing ByteJSON modifier/rebuilder, constructor conversion and prepared parameter metadata; it does not add a second JSON execution path. Checked left-to-right pair effects, append/reverse underflow, absent/non-array parents, SQL NULL versus JSON null, invalid terminals/wildcards/ranges, size/depth admission, binary FLOAT execution, and existing shared callers. Cost remains proportional to document/array copying per effective pair, including the existing repeated-copy cost for multiple pairs; no throughput improvement is claimed and no new benchmark framework is warranted.

The unrelated SYSDATE/SLEEP correction keeps the lower-bound and successful-return assertions: scheduling can resume later than the requested two seconds, so exact equality was not the promised behavior. It does not weaken a product upper-bound latency guarantee. Existing case count and production timer semantics are unchanged.

Fresh reviewer execution on this head (Go 1.27.0, Darwin arm64, native libraries rebuilt through make cgo):

  • Complete pkg/container/bytejson: PASS, exit 0.
  • Focused ARRAY_INSERT/strict-parent/depth/error tests, function dispatch and fixed function IDs: PASS.
  • Planner prepared JSON value-position regression and actual MYSQL_TYPE_FLOAT binary frontend execution: PASS.
  • git diff --check: PASS.
    A first raw go-test invocation failed to load local native libraries and executed no test; the controlled, freshly built runs above supersede that setup attempt. No live service BVT, race or benchmark is newly claimed here. Author full owning-package/BVT evidence is reused only for unchanged semantic closure and remains bound to its recorded revision.

Current-head CI Required/SCA/UT/PROXY/pessimistic BVT/coverage checks are green. Actual main was refreshed as 56478b6; function ID 586 is still unallocated there, while 584/585 retain their existing definitions. Recheck allocation if landing main changes. The existing series design applies; broader issue #28033 and deployed QA are not declared complete by approval of this partial feature. Mixed-version rolling-upgrade testing is outside this requested review scope.

@mergify mergify Bot added the queued label Oct 8, 2026
@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-08 11:47 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-08 12:37 UTC · at 37b4ff39dc9125da1424c5a19f0cd750b500709d

This pull request spent 50 minutes 14 seconds in the queue, with no time running CI.

Reason

Pull request #29519 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit d33bb6e into matrixorigin:main Oct 8, 2026
@mergify mergify Bot added dequeued and removed queued labels Oct 8, 2026
XuPeng-SH pushed a commit that referenced this pull request Oct 9, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue #29764

The reported premise is corrected rather than implemented: a NULL
**value** is inserted as JSON null. A NULL document or path returns SQL
NULL. The issue remains open for QA and clarification.

## What this PR does / why we need it:

Preserve the existing JSON_ARRAY_INSERT NULL-value behavior and add
regression coverage. The previous PR head introduced an incorrect
SQL-NULL shortcut that also bypassed document/path validation and
changed missing/non-array-parent no-ops. This update removes that
shortcut and uses the existing value converter and bytejson insertion
path. Relative to the target base, production code changes only an
explanatory comment.

The independent expected result comes from version-pinned [MySQL 8.0.40
ARRAY_INSERT
implementation](https://github.com/mysql/mysql-server/blob/mysql-8.0.40/sql/item_json_func.cc#L2176-L2255),
its [SQL NULL to JSON null
conversion](https://github.com/mysql/mysql-server/blob/mysql-8.0.40/sql/item_json_func.cc#L1646-L1658),
and the [official NULL MTR
case](https://github.com/mysql/mysql-server/blob/mysql-8.0.40/mysql-test/suite/json/r/json_functions_innodb.result#L4824-L4830):
a nullable value column produces `[[null, 1]]`, not SQL NULL. This
contradicts the manual's blanket NULL wording. No live MySQL execution
is claimed.

Coverage includes literal/column NULL, a later NULL path-value pair,
adjacent non-NULL rows, typed JSON null, missing/non-array parents,
invalid documents/paths, SQL-NULL document/path controls, and a JSON NOT
NULL column. The canonical BVT also verifies that a failed UPDATE
preserves the document and that the next statement works. Prepared
binary parameter rebinding covers non-NULL -> NULL -> non-NULL and MORPC
51/52 without introducing a new protocol path. ARRAY_APPEND behavior is
unchanged and outside this issue's scope.

Validation on the repaired content:

- The corrected function tests fail with the previous NULL shortcut
restored and pass after its removal.
- CGO-enabled `TestJsonArrayInsert`: PASS; complete
`pkg/sql/plan/function`: PASS.
- `TestInitExecuteStmtParamDirectBinaryConstructor`: PASS.
- `make build`: PASS.
- `test/distributed/cases/function/func_json_array_insert.sql`: two
normal mo-tester runs, each 45/45 successful, no ignored cases; table
teardown confirmed. Generated expectations were separately checked
against the pinned oracle and SQL contract before comparison runs.
- `git diff --check`: PASS.
- Complete `pkg/frontend`: FAIL in eight unrelated RETURNING spool tests
due to allocation admission cap=1. The same eight failures reproduce
with the original frontend test file; this is retained as a baseline
validation limitation, not reported as PASS.

Self-review covers the complete final diff and affected conversion, path
validation, prepared rebinding, SQL write/error and teardown paths. The
former semantic PASS based on the incorrect NULL oracle is superseded;
no new independent Astra review is claimed.

Dependency: [PR
#29519](#29519), already
merged as `d33bb6e8b926f150b78f97249ae73da7b2a98a4e` and present in this
branch; no outstanding merge-order dependency.

QA required: yes. Automated SQL tests cover the user-visible result, NOT
NULL write and failed-statement recovery. Live MySQL cross-engine
comparison and deployment QA remain NOT_RUN; CI and maintainer review
remain separate from local validation.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@VioletQwQ-0
VioletQwQ-0 deleted the codex/issue-28033-json-array-insert branch December 1, 2026 03:47

This branch had an error being deployed

1 failed deployment
ci — 37b4ff39 Deployed Oct 8, 2026 by mergify[bot]
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 kind/feature size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants