Skip to content

[Bug]: JSON arithmetic loses fractional values beside an integer operand #29470

Closed

Description

@XuPeng-SH

Existing issue check

Searched existing MatrixOne issues before filing.

Branch / commit

main history; reproduced using the clean direct-parent benchmark binary for 1575e70c3db676d3ed00abc080aadc029b0e1435, fresh copy of its data snapshot, Linux amd64, local single CN on NVMe. Discovered while reviewing #29462; these ordinary SQL failures do not require prepared execution.

Actual behavior / reproduction

select cast('1.6' as json)+0;

Observed: 1. Expected: 1.6.

Root cause / correction

Arithmetic type selection borrows an integer peer's domain for a JSON scalar, casting the fractional JSON value to an integer before arithmetic. JSON's numeric evaluation must preserve a fractional scalar. This is independent of the special JSON comparison rules.

The correction in #29462 normalizes JSON numeric operands to DOUBLE while selecting arithmetic overloads, including division, without changing comparison/explicit CAST rules. Focused typed-source and owning function/planner package tests pass; final PR acceptance remains pending.

Activity

  1. added
    kind/bug
    on Sep 29, 2026
  2. self-assigned this
    on Sep 29, 2026
  3. added a commit that references this issue on Sep 29, 2026
    a36da7f
  4. Ariznawlll commented on Oct 2, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • Commit:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 部署方式:本地全新单 CN mo-service,独立数据目录;MySQL 文本协议与 server-side PREPARE
    • 测试日期:2026-10-02

    原问题验证

    按 issue 原始语义在上述 commit 重新执行并重复 3 次。JSON numeric 1.6 与 0 相加结果保持 1.6,不再被整数化。

    Happy Path 覆盖

    覆盖 JSON 整数、小数和负数与数值 operand。

    Unhappy Path 覆盖

    覆盖 JSON null、非法 JSON、NULL SQL 值;无 silent truncation。

    白盒验证

    关联修复 #29462 已进入当前 main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。

    回归测试

    测试证据

    • 精确测试版本:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 当前结果:JSON numeric 1.6 与 0 相加结果保持 1.6,不再被整数化。
    • 回归代码与 golden result 已提交到 MOTR #209;本地全量 14_issue_regression 中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions