Skip to content

fix(json): support JSON_MERGE compatibility alias - #28329

Merged
mergify[bot] merged 11 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28033-json-merge-design
Sep 15, 2026
Merged

mergify[bot] merged 11 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28033-json-merge-design

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 #28033

What this PR does / why we need it:

PR1 of the #28033 JSON compatibility series. This PR implements the approved JSON_MERGE compatibility alias while keeping the umbrella issue open for the remaining three functions.

Implementation and review repairs:

  • Register json_merge as an alias of JSON_MERGE_PRESERVE; no new function ID, overload, or executor is introduced.
  • Emit MySQL 8.0.45 warning 1287 with the exact deprecation text once per successful syntactic call site, using the original *tree.FuncExpr for call-site deduplication. The previous undefined astExpr compile blocker is removed.
  • Carry a reusable warning lifecycle through plan construction. CTAS source metadata/privilege planning and definition-change compile retry reuse the same call-site set; txnExecutor.Exec marks each generated internal statement context as JSONMergeWarningInternalReprepare, so internal prepared reprepare and stored-view expansion suppress duplicate warnings while the context is restored before the next user statement.
  • Start a fresh lifecycle for each user statement and all PREPARE representations. Ordinary COM_QUERY statements containing JSON_MERGE bypass plan-cache lookup and insertion so a cached plan cannot lose warning 1287.
  • Add focused tests for the production retry entry, prepare forms, cache eviction, scanner boundaries, and canonical CTAS/cache BVT coverage.

Dependencies and merge order:

Non-goals:

  • No Fixes #28033 closing reference, issue closure, merge, branch deletion, or post-merge cleanup.
  • No implementation of JSON_DEPTH, JSON_ARRAY_INSERT, or JSON_SEARCH in this PR.

Validation (exact PR head 15c72c9aa7265a16000fad34e09e89def5074ee9, base 363f8c3fe63ab21f19d8e9ba854c24d2dcaadfc3):

  • Review base: FAIL — the base registry has no json_merge entry, so the alias cannot bind.
  • Semantic preflight: PASS; schema-v7 manifest diff hash 08bfd5a97377686a288e6f941e0ed65af6d1501cb615feb983ebb8e4d0d28928.
  • Publication delta: the reviewed six-file follow-up is exactly 34 additions and 1 deletion; git diff --check: PASS.
  • Focused UT and canonical BVT sources are included, but local execution is pending: the required mo-cgo-test wrapper cannot start because this worktree and its primary worktree lack the required cgo/libmo.dylib/matching native artifacts. The ordinary go test fallback is not acceptance evidence and is not claimed as PASS.
  • Exact-head CI must provide the compile and runtime evidence for the repaired binder, CTAS/cache lifecycle, prepared replan, and BVT expectations before merge.
  • QA required: yes. Use MySQL 8.0.45 as oracle and report MatrixOne version, environment, and explicit PASS/FAIL for prepared warning/reprepare, view warning, CTAS duplicate suppression, ordinary cache reuse, NULL/invalid/arity behavior, and row-scan warning cardinality before MySQL JSON APIs are unavailable or reject valid calls #28033 can close.

@matrix-meow matrix-meow added the size/XS Denotes a PR that changes [1, 9] lines label Sep 7, 2026
@mergify mergify Bot added kind/bug Something isn't working kind/documentation Improvements or additions to documentation kind/api-change labels Sep 7, 2026
@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed the three design review findings in 33e96ff6fe7dfe734a684a66c0a420c79aef5f7d:

  • JSON_ARRAY_INSERT: forward overflow appends, while reverse last-N underflow clamps to index 0 and inserts at the head; the validation plan now requires a nonempty-array regression case.
  • JSON_SEARCH: documented normal versus NO_BACKSLASH_ESCAPES behavior for omitted, SQL NULL, empty, and custom escapes, including exact ER_WRONG_ARGUMENTS behavior and prepared rebind mode resolution.
  • JSON_MERGE: added explicit warning-origin propagation so internal rebuildPreparePlan and stored-view expansion suppress duplicate 1287 diagnostics while a new user PREPARE still warns once per call site; added the schema-change EXECUTE/SHOW WARNINGS scenario.

The PR body now records the repaired exact head and semantic preflight result. It remains Draft pending design re-review; no executable code or BVT case changed in this documentation-only revision.

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

Independent design review of docs/design/mysql_json_compat_28033.md at 33e96ff: APPROVED for the proposed staged contracts. This revision changes only that document; it is not an implementation approval or permission to merge an extra design-only PR.

The design distinguishes alias reuse from new executors, preserves constructor conversion ownership, separates warning origin from executable-plan rebuilding, and supplies explicit NULL/error, path, resource and QA contracts. Reverse-index underflow has a discriminating nonempty-array case; SEARCH includes the mode/escape/prepared-rebind matrix; MERGE warnings are per syntactic bind origin rather than per row or internal reprepare. The ordered implementation sequence and non-closing umbrella issue remain explicit.

Implementation acceptance must still establish the documented behavior with the pinned MySQL oracle and exact-head UT/BVT, including warning counts after schema-triggered reprepare and bounded traversal/cancellation on deeply nested inputs. I have not run an independent MySQL probe or any runtime test for this documentation-only head. Re-review every implementation head; keep the declared prerequisite/Draft holds until then. Refresh stale prerequisite status in the body when beginning implementation (for example #28090 has since merged).

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Rebased this Ready PR onto the latest main.

  • New base: upstream/main@f0c31cd4b830be32442cf329e0a3fb08aa9c16c3
  • New exact head: e8037db842180f3de4c2c295851e0b6a328fdc85
  • git diff --check: PASS
  • Exact-head schema-v7 semantic preflight: PASS
  • Manifest diff hash: 4bfbbb37ed8437d47c5a6ae2eb555c059d8ada28821cdfcdc25b94608abb81b6

The PR remains Ready for review. Rebase invalidated the previous CI run; fresh exact-head checks are running. No merge or Issue #28033 closure was performed.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Updated at exact head 48bc8068c91133822a074699bd0337a3b03e0ae6 (frozen-base parent 363f8c3fe63ab21f19d8e9ba854c24d2dcaadfc3).

  • Preserved the JSON_MERGE_PRESERVE compatibility alias and warning 1287 lifecycle: one warning per syntactic call site, internal reprepare/stored-view suppression, CTAS fresh-AST deduplication, and compiler-context restoration.
  • Made the pre-bind scanner honor NO_BACKSLASH_ESCAPES so real calls cannot bypass warning setup or plan-cache exclusion. Corrected the canonical BVT warning-row terminator for the two-call-site case.
  • Focused regression coverage now includes lifecycle, CTAS rebind, plan-cache exclusion, scanner boundaries, PREPARE/reprepare, and canonical BVT cases. Static evidence passes: gofmt, frozen-base diff-check, clean-tree exact-content preflight (3b5aa90be7903b0dd8836b7da4f1c26d24c9434a780caf857f92c94ed4619c96).
  • Local CGo focused execution remains blocked by missing cgo/libmo.dylib; vet is blocked by docfilter CGo symbol resolution. Prior run 34308341241 coverage/PROXY failures and cancelled UT remain historical CI blockers; fresh CI is pending. No approval or QA claim.

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

What is the result of merging two dictionary, one has "a" : { "foo": "bar"}, the other is "a": ["foo", "bar"]?

@fengttt

fengttt commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

What is the result of merging two dictionary, one has "a" : { "foo": "bar"}, the other is "a": ["foo", "bar"]?

And is dictionary merging recursive? I cannot find these answers and I did not see any test covering these.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Under this PR's JSON_MERGE alias, the result follows JSON_MERGE_PRESERVE: object members recurse only when both values are objects. When one value is an object and the other is an array, the conflicting values are combined as an array and the array elements are flattened. Thus {"a":{"foo":"bar"}} merged with {"a":["foo","bar"]} produces {"a":[{"foo":"bar"},"foo","bar"]}; reversing the operands produces {"a":["foo","bar",{"foo":"bar"}]}.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Current-head CI diagnosis (head f9f3232ab40b3558e2cd54d0ad5162ccbc486baa, run 34558703844):

  • Ubuntu/x86 UT job 103137131748 failed in pkg/logservice at TestTickerForTaskSchedule under -race; the log reports a race between idAllocator.Capacity() and idAllocator.Next() in pkg/logservice/store_hakeeper_check.go, followed by race detected during execution of test.
  • The PR diff is limited to JSON merge/planner/frontend and related test/design files; it does not touch pkg/logservice. I classify this as an unrelated CI/test race, not a PR-specific test conclusion.
  • No CI rerun was performed. Please rerun or repair the failing test baseline before using this result as PR evidence.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Current exact-head CI review (ebcdd68274e97ebbce3f0fcb32355a18fd976ae1 on main@2ea4ec2e6ef4b20321a235ef416228506813e39b).

Ubuntu UT job 104231934552 failed in the untouched shared test pkg/vm/engine/test/TestISCPExecutor6 (change_handle_test.go:3210,3232): the ISCP watermark remained 0-0 instead of advancing to the expected value, then the test context was cancelled. The PR diff does not touch pkg/vm/engine/test, ISCP, or watermark code, so this is not attributable to #28329. CI Required job 104259606964 is a derived failure from matrixone-ci: failure, not an independent product result.

I classify this as INCONCLUSIVE shared-test/baseline instability pending a same-base comparison; no code or test change is justified from this run, and I did not blindly rerun it. The PR's JSON_MERGE review/QA gates remain separate.

@mergify

mergify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-15 20:56 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-09-15 22:07 UTC · at 8fdb1524d5cce45ebc801ab1b419c7b7eb5373d6 · squash

This pull request spent 1 hour 10 minutes 41 seconds in the queue, including 1 hour 10 minutes 19 seconds 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/api-change kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants