Skip to content

Fix returned JSON numeric comparison boundary cases (#30539) - #31719

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/issue-30539-json-boundary
Nov 1, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/issue-30539-json-boundary

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Fixes #30539

What this PR does / why we need it:

QA returned #30539 after the previous fix (#30707): mixed JSON/numeric comparisons still reject valid JSON numbers outside an integer peer's CAST range. This follow-up fixes the returned numeric-boundary cases. A JSON value of 128 compared with a TINYINT 1, UINT64_MAX compared with BIGINT 1, or 1e100 compared with integer 1 aborts the query instead of producing a nonmatch.

Compare JSON numeric rows through the existing exact integer/decimal comparator without imposing the integer peer's width or signedness. Retain numeric parameter adapter validation, explicit CAST behavior, and existing floating-point conversion semantics. The correction removes a per-row integer conversion and adds no allocation, state, storage, or wire-format changes.

Update the existing direct/prepared comparison suites and JSON_EXTRACT BVT with numeric boundaries, negative/unsigned comparisons, all operators and operand orientations, precision and NULL/category controls, prepared reuse, scalar subqueries, joins, and explicit CAST errors.

Validation on macOS arm64, Go 1.27.1:

  • New regression assertions fail on unchanged production at official main 792a65b with the reported JSON-to-integer errors, then pass with the fix.

  • Focused JSON comparison tests and the complete function package pass (2360 top-level tests); incremental go vet and golangci-lint pass.

  • Repository native and mo-service builds pass. The JSON_EXTRACT BVT passes 342/342 commands twice on one isolated 1 LOG / 1 TN / 1 CN instance, with database/table teardown verified between and after runs. The three returned QA queries (TINYINT 128, UINT64_MAX, and 1e100) each return only id=1. Projection, reversed comparisons, JOIN, prepared execution/reuse, and explicit CAST controls also pass.

  • GPT-6 Astra medium design and integrated final review recorded locally. Local checks passed on commit b18e042; remote PR CI is pending.

  • CI repair validation on 9c1c2fe (macOS arm64, Go 1.27.1): coverage run 40836203108 exposed three consumer tests still expecting the integer-range errors removed by this fix. All three reproduced locally before the test correction. Updated selected-row, ASOF, direct SQL and prepared SQL assertions; retained FLOAT32 range/rebind, residual-error propagation/reuse, and explicit CAST rejection controls. The complete colexec/hashjoin packages and the full TestIssue27529JSONStringsDoNotCompareAsBooleans fixture pass via mo-cgo-test with -count=1 -short -tags matrixone_test -covermode=set; focused JSON consumer tests, incremental vet and lint also pass. Function-package CI (14.312s) and prior build/BVT evidence above are reused because their inputs are unchanged. This follow-up changes tests only; new-head CI is pending.

  • CI refresh on 6c2d00a, rebased onto official main 950ef51: git range-diff confirms both original patches are unchanged. Focused JSON domain, direct-type resolution, adapter metadata/reuse, coercion, selected-row and ASOF tests, plus the full TestIssue27529JSONStringsDoNotCompareAsBooleans SQL fixture, pass on macOS arm64/Go 1.27.1 through mo-cgo-test -count=1 -short -tags matrixone_test; incremental vet/lint for all four affected packages and delivery-artifact checks pass. Prior unchanged-comparator/package/BVT evidence above is reused. In run 41273226176, SCA, UT Coverage, Coverage and both BVT lanes passed; ordinary race UT failed while initializing the shared two-CN fixture for TestAutoIDCachePublicLifecycle, before its callback. This refresh does not claim that startup failure is fixed or proven unrelated; new-head full CI remains pending.

FLOAT32 rounding/range checks and FLOAT64 conversion retain their existing contract. This focused stateless comparison correction does not change planner eligibility, RPC capability, or distributed execution paths; multi-CN and rolling upgrade were not exercised.

@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 added the kind/bug Something isn't working label Oct 29, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 29, 2026
@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 9c1c2fee49a0138074fa0f4df15dae03f7c5647a

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: 9c1c2fee49a0138074fa0f4df15dae03f7c5647a

Assessment: approve

The fix removes inappropriate integer narrowing from implicit JSON comparisons while preserving parameter validation, floating-point behavior and explicit CAST errors. Consumer tests retain error propagation and reuse coverage. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Reviewed all eight changed files, affected consumers, both discussion entries and linked QA follow-ups.

  • Static checks and independent numeric/golden oracles passed. Receipt: checks/1793277328664726898-2.json; log: review-check.log.

  • Reused supplied current-head UT, coverage, SCA, build and BVT success; verified earlier author-tested production/function/BVT inputs are unchanged.

  • Saved review-plan.md, discussion-assessment.json and validation-audit.json.

Limitations:

  • No Go or SQL tests were rerun locally; raw per-test CI and author logs were not supplied.

@mergify

mergify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

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

Approved. The change removes the integer-peer range check from JSON-row comparison while retaining validation of the prepared numeric peer and the existing floating-point path. I checked the comparison orientations, wider signed/unsigned values, prepared reuse, explicit CAST controls, and caller regressions. No blocking issue found. I reused passing product CI and the documented validation; no separate local service test was run.

@mergify

mergify Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

queue

🛑 Pull request from fork cannot be queued

Details

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.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

queue

🛑 Pull request from fork cannot be queued

Details

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.

@mergify

mergify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

42 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Sun 1 Nov, 07:53 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 08:35 · dd5266a

Reason

Pull request #31719 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.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

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

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit 28a9331 into matrixorigin:main Nov 1, 2026
@mergify mergify Bot added dequeued and removed queued labels Nov 1, 2026
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Nov 1, 2026
…mixed-domain contract

The rebase onto main (adopting matrixorigin#31719) exposed four consumer assertions in
pkg/tests/issues still pinning the pre-matrixorigin#31121 conflation semantics that this
branch removes deliberately:

- issue_27529_test.go: the '{"active":null}' row expected SQL NULL folding; a
  character parameter 'true' was expected to parse into the JSON boolean
  document; object/array JSON vs a prepared boolean peer expected the removed
  JSON -> BOOLEAN cast error.
- issue_27187_test.go: the '{"enabled":null}' row expected the same SQL NULL
  fold.

JSON literal null is a ranked value and a character parameter is a JSON string
scalar in every mixed domain (inventoried in func_json_scalar_semantics_31121
and func_json_extract.result on this branch), so those rows now expect valid
false / ranked-comparable results. Each row was reproduced red on the rebased
head before the correction and both fixtures pass afterwards.
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Nov 2, 2026
…mixed-domain contract

The rebase onto main (adopting matrixorigin#31719) exposed four consumer assertions in
pkg/tests/issues still pinning the pre-matrixorigin#31121 conflation semantics that this
branch removes deliberately:

- issue_27529_test.go: the '{"active":null}' row expected SQL NULL folding; a
  character parameter 'true' was expected to parse into the JSON boolean
  document; object/array JSON vs a prepared boolean peer expected the removed
  JSON -> BOOLEAN cast error.
- issue_27187_test.go: the '{"enabled":null}' row expected the same SQL NULL
  fold.

JSON literal null is a ranked value and a character parameter is a JSON string
scalar in every mixed domain (inventoried in func_json_scalar_semantics_31121
and func_json_extract.result on this branch), so those rows now expect valid
false / ranked-comparable results. Each row was reproduced red on the rebased
head before the correction and both fixtures pass afterwards.
mergify Bot pushed a commit that referenced this pull request Nov 3, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

- #30539

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

Comparing a valid JSON number such as `1e100` with a FLOAT currently fails the whole query when the JSON value exceeds the FLOAT32 range. Compare out-of-range JSON values using their FLOAT64 value while preserving FLOAT32 rounding inside its range and the existing validation of the FLOAT peer. Explicit CAST behavior remains unchanged.

This follows up on #31719, which removed the integer-domain restriction but retained the FLOAT32 range check.

### Validation

- Focused JSON numeric and direct/prepared comparison unit tests; full function Go package, vet and lint passed on the same product code.
- `function/func_json_extract.test`: 364/364 twice; ASOF: 74/74; join: 1254/1254 on a single-node instance.
- The full function directory exited with 105 failures in four cases that hard-code port 6001 while the test instance used 37101. With only those case ports changed in temporary copies, all 166/166 assertions in those four cases passed. The original directory run did not pass.
- Historical MySQL 8.0.45 comparisons covered the reported `1e100` equality case in both directions. MySQL FLOAT32 adjacent values were not measured, and no FLOAT performance benchmark was run. CI remains pending.

### CI repair validation (8bd4755)

The [coverage failure](https://github.com/matrixorigin/matrixone/actions/runs/41617804875/job/125855672749) at `840bed3237960971b9c03eb62ef47ac52f820a8a` was reproduced locally: `TestPreparedJSONComparisonSelection` still expected JSON `1e100` versus FLOAT to fail. Updated that consumer oracle to assert nonmatching results for positive/negative out-of-range JSON values, selected rows, and FLOAT → DOUBLE → FLOAT rebinding. Product code is unchanged by this repair.

New validation on Darwin/arm64, Go 1.27.1 at `8bd475530ba03fca6f9abec32cc1d2da2faca1a5`:
- `mo-cgo-test -count=1 -timeout=120s -short -tags matrixone_test -covermode=set -run '^TestPreparedJSONComparisonSelection$' -v ./pkg/sql/colexec`: passed.
- `mo-cgo-test -count=1 -timeout=240s ./pkg/sql/colexec ./pkg/sql/plan/function`: both full packages passed.
- `go vet -mod=readonly` and incremental `golangci-lint run --new-from-rev c337122` for those two packages, with repository CGo inputs: passed (0 lint issues).

The earlier SQL/BVT results above are reused because product code and BVT inputs did not change. Linux/x64 CI for this repair remains pending; the failed old run is not rerun.


Approved-by: XuPeng-SH <[email protected]>

This branch was successfully deployed

No deployments
ci — dd5266a3 Deployed Nov 1, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

[Bug]: Comparing JSON_EXTRACT with a number aborts the query on non-numeric JSON values

4 participants