Skip to content

[Compatibility]: set operations merge signed-zero floats unlike MySQL #30155

Closed

Description

@Ariznawlll

Description

MatrixOne collapses -0 and +0 in duplicate-eliminating set operations on FLOAT/DOUBLE, while MySQL 8.0.46 preserves the two signed-zero values as separate set members. As a result, UNION, INTERSECT, and EXCEPT return different row counts/membership across the two servers.

The MySQL compatibility contract README was checked and does not document signed-zero set-operation behavior as an exception. Existing reports #27425 and #28856 cover MatrixOne's internal signed-zero handling in aggregate paths; neither covers this set-operation difference. This issue is scoped to set-operation compatibility and does not reopen those closed issues.

Environment

  • MatrixOne SQL runtime: 8.0.30-MatrixOne-v1.3.0, local single-CN/TN/LogService environment; the server binary was built from source commit 2ce4e58af6f03b943ee288ffad81012766cf830a.
  • Current official main at report time: a53390c57de48ac280249ff0e88831e502e20fb0 (10 commits ahead). The comparison contains no changes to the float key canonicalization/comparison or set-operation implementation paths; the runtime build SHA is stated separately rather than attributed to current main.
  • MySQL comparison server: 8.0.46.

Steps to reproduce

CREATE TABLE signed_zero_setop(id INT PRIMARY KEY, x DOUBLE);
INSERT INTO signed_zero_setop VALUES (1, -0e0), (2, 0e0);

SELECT COUNT(*)
FROM (
  SELECT x FROM signed_zero_setop WHERE id = 1
  UNION
  SELECT x FROM signed_zero_setop WHERE id = 2
) q;
-- MatrixOne: 1
-- MySQL:     2

SELECT -0e0 INTERSECT SELECT 0e0;
-- MatrixOne: -0
-- MySQL:     empty result

SELECT -0e0 EXCEPT SELECT 0e0;
-- MatrixOne: empty result
-- MySQL:     -0

The same UNION row-count difference was observed with both FLOAT and DOUBLE columns. DECIMAL -0.00/0.00 controls collapse to one row on both servers.

Stability and controls

  • UNION count: MatrixOne 1/1/1, MySQL 2/2/2.
  • INTERSECT count: MatrixOne 1/1/1, MySQL 0/0/0.
  • EXCEPT count: MatrixOne 0/0/0, MySQL 1/1/1.
  • Same-sign duplicate UNION returns one row on both.
  • UNION ALL retains both rows on both (unordered row order is not compared).
  • -0e0 = 0e0 returns true on both.

Expected behavior

If MatrixOne's MySQL compatibility contract includes set-operation duplicate semantics for FLOAT/DOUBLE, the row counts and membership should match MySQL 8.0.46 for these signed-zero inputs. The exact results above distinguish this from scalar equality and UNION ALL behavior.

Related

Activity

  1. added this to the MO-202610 milestone on Oct 14, 2026
  2. added
    kind/bug
    kind/compatibility
    on Oct 14, 2026
  3. added theissue type on Oct 14, 2026
  4. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    QA follow-up for PR #30184 at current head f4d2b87d4467b9e40c1a4eba6cd985f4ad27524e (2026-10-22).

    The latest commit is chore: format planner helper; its commit diff only removes a blank line in pkg/sql/plan/flatten_subquery.go. The prior exact-code review on 13d1d28c approved the signed-zero set-operation fix and reported 70 test roots across 14 packages, SQL probes under text/binary prepared execution, and exact-head CI. These are retained review/CI evidence; I did not rerun Go tests. The current head has no combined checks; the only visible workflow is unrelated Iceberg Connector E2E (success).

    I added Ariznawlll as an additional tester assignee and kept existing assignee iamlinjunhong. Please verify the FLOAT/DOUBLE -0/+0 UNION/INTERSECT/EXCEPT cases after the fix reaches main; keep this issue open for reporter confirmation. The review's limitation on fresh performance and live mixed-version testing remains noted.

    Synchronize checkpoint — 2026-10-22

    The PR has since synchronized onto main@65b0738e3a50dbfb5b7c2b99de04a8b8c040ed1e; current head is 3e0a8422f3a6b833b7e907fcfa3903fc2bd4ef5f (PR remains open). The latest commit advances this PR's set-key/scalar capability from MORPC 129 to 130 because the synchronized base now assigns 129 to selected JSON ELT/opaque-text execution. I checked the base and head protocol constants and the 14-file commit: the feature's placement, destination, send/receive, executor, CTAS and persisted-expression gates and tests move together; boundary tests retain rejection below 130 and acceptance at 130. No new actionable issue found in this protocol-number update.

    The exact-head combined status is empty. The only returned PR workflow is Iceberg Connector E2E (in progress), unrelated to SQL set operations. The PR body records updated official-main 129 / set-key 130 evidence and says new-head CI was triggered; those are author-provided records, not independent test execution. No submitted review after the earlier approval on 13d1d28c is present. This workspace is a shallow checkout on another SHA and has no Go runtime, so I could not run the protocol/planner/compiler tests locally.

    Issue #30155 remains open and assigned only to iamlinjunhong; no assignment or status change. Keep it with the implementer until the PR lands, then run the FLOAT/DOUBLE signed-zero UNION/INTERSECT/EXCEPT probes on the merge commit before handoff.

  5. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    Correction to my previous QA follow-up on this issue.

    #30184 (fix(sql): preserve signed zero in float set operations) is still OPEN and not merged into main, so per the QA transfer rule a hand-off to testing is premature: there is nothing on main for QA to verify yet.

    Action taken: removed Ariznawlll from the assignees and restored iamlinjunhong as the sole owner, so the issue stays with the implementer until the fix lands. I will re-assign to QA (single assignee, dropping the implementer) once #30184 is merged and I have re-run the signed-zero UNION/INTERSECT/EXCEPT probes on a build of the merge commit.

    My earlier request to verify "after the fix reaches main" was the wrong sequencing.

  6. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    QA finding for PR #30184 — last reviewed head 6424439

    The prior submitted review reported a P2 SQL regression in pkg/sql/plan/correlated_scalar_set.go:43: the blanket subtreeContainsAggregate exclusion disabled scalar-set reaggregation when a UNION arm contained an aggregate independent of the outer correlation, and the arm-reuse proof stopped at the JOIN.

    Reported base/head probe: with ot(i INT NOT NULL) = (1),(2),(3) and it(i INT NOT NULL, f DOUBLE NOT NULL) = (1,2.5),(2,2.5),(3,2.5), a correlated scalar subquery whose two identical UNION arms each join it to (SELECT MAX(i) m FROM it) returned 2:2.5 at merge base 060cb430e9ff59e60dc7bdade05758d343516acb, but failed at head 6424439c70dcdeea3f52a3f62f01599d679fe145 with error 20102: “correlated UNION branch identities differ or have unresolved types.” The corresponding single-arm DISTINCT control passed on both.

    Synchronize checkpoint — 2026-10-22

    PR #30184 is still open and unmerged. Its current head is 1b9d9fd0d37619912adb307fcbb0fd7a2b6a3ad0 (fix(plan): retain independent aggregates in scalar sets). I inspected that commit's diff: it changes admission from rejecting any aggregate to rejecting only correlated aggregates, and adds planner and SQL integration regression cases for the independent aggregate JOIN shape above. This is a code-level indication that the reported case is addressed; I have not independently run the new tests or the SQL repro on this head.

    The exact-head combined commit status returned no status checks. The only workflow run returned for this SHA is unrelated Iceberg Connector E2E (success). The PR description includes author-reported validation, but that is not treated here as my execution. The current workspace has no MatrixOne checkout/Go runtime, so local targeted execution is unavailable.

    Issue #30155 remains open and assigned only to iamlinjunhong. No issue state or assignee change: keep it with the implementer until the fix is merged and the signed-zero compatibility probes plus this correlated aggregate regression are verified on the merged build.

  7. 2 remaining items

  8. XuPeng-SH commented on Oct 23, 2026

    @XuPeng-SH
    Contributor

    QA update — PR #30184 approval on current head

    XuPeng-SH approved exact head dc9467a31a49b31b5893f908b37ff32e1f803817 on 2026-10-23. The approval reports the protobuf decoder/generator blocker fixed, four inline review threads resolved, and focused tests across pkg/pb/plan, pkg/pb/pipeline, and the string-literal postprocessor passing (89 top-level tests); it also reports postprocessor idempotence and linear nested-decode benchmark scaling.

    I independently checked the GitHub workflow record for that SHA: run 39871389802 completed successfully for UT, SCA, coverage, PROXY and PESSIMISTIC BVT, and CI Required. The local workspace has no MatrixOne checkout or Go runtime, so I did not rerun tests locally.

    PR #30184 and this issue remain open; the issue stays assigned to the implementer until the fix is merged and the merge commit is verified.

  9. XuPeng-SH commented on Oct 23, 2026

    @XuPeng-SH
    Contributor

    Verification and tester handoff — PR #30184 (2026-10-23)

    XuPeng-SH approved exact head dc9467a31a49b31b5893f908b37ff32e1f803817 in review 5631499611. The review records the signed-zero fix and protobuf decoder correction, 89 focused protobuf/postprocessor tests, 175 signed-zero subcases, and successful exact-head CI run 39871389802; these are reviewer-verified receipts, not tests I reran locally. This resolves the tracked set-operation compatibility finding for tester follow-up. Issue remains open; assigned to Ariznawlll for verification.

  10. iamlinjunhong commented on Oct 26, 2026

    @iamlinjunhong
    Contributor

    Following review on #30184 (fengttt): MatrixOne will not match MySQL's signed-zero set membership here.

    MatrixOne equality treats -0 and +0 as equal, and set operations follow that equality. main already normalizes FLOAT/DOUBLE hash keys (keycodec.CanonicalFloat32Bits / CanonicalFloat64Bits: both zeros become 0, and all NaN encodings become one canonical NaN). The current results are therefore the intended behavior:

    Query (opposite signed zeros) MatrixOne MySQL 8.0.46
    UNION 1 row 2 rows
    INTERSECT 1 row empty
    EXCEPT empty 1 row

    Which zero is displayed depends on the input order, and is not part of the contract.

    #30184 no longer changes behavior; it only adds regression tests locking the 1/1/0 results (including the ALL variants). For verification, please check those counts on main rather than MySQL's 2/0/1.

  11. added
    ai-light
    on Oct 29, 2026
  12. Ariznawlll commented on Oct 29, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试通过。按研发确认的 MatrixOne 契约,FLOAT/DOUBLE 的 -0 和 +0 在集合运算中按数值相等处理;该语义与 MySQL 8.0.46 原报告的结果不同。

    关键证据

    • 研发决策见 #30155 评论;回归 PR #30184 已合入,不改变上述语义。
    • 在执行时官方 main@641c34d259447a6b70ce1ce0615a610e9d1a108e 的隔离本地 1 CN、1 TN、1 LogService 上验证,运行版本为 641c34d259。FLOAT/DOUBLE 两种列类型及左右输入互换均 3/3:单行 -0 与 +0 的 UNION、INTERSECT、EXCEPT 行数依次为 1、1、0;UNION ALL 为 2,INTERSECT ALL 为 1,EXCEPT ALL 为 0。标量相等、NULL 和不同非零值对照通过;不要求输出零的符号固定。
    • 原 issue 报告的 MySQL 8.0.46 对照依次为 2、0、1;本次未重复运行 MySQL。兼容性行为已提交到指定仓库的文档 PR #44,尚未合入。
    • MOTR #294 新增 FLOAT/DOUBLE 集合语义回归,定向 3/3 通过、39/39 语句成功;测试库已清理并复查不存在。

    待解决点

    • 文档 PR 和 MOTR PR 均尚未合入;MOTR CI 因 Actions 预算限制未启动,完整 MOTR suite 未运行。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-lightarea/compatibilitykind/bugkind/compatibility

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions