Skip to content

fix(agg): preserve nullable groups in AP MergeGroup - #24223

Merged
mergify[bot] merged 8 commits into
matrixorigin:mainfrom
gouhongshen:fix-issue-24208-division-decimal-upstream-old
Apr 29, 2026
Merged

mergify[bot] merged 8 commits into
matrixorigin:mainfrom
gouhongshen:fix-issue-24208-division-decimal-upstream-old

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Apr 27, 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:

Closes #24208

What this PR does / why we need it:

This PR fixes the real root cause behind the unstable q34 result on MatrixOne.

On the AP one-CN parallel merge path, MergeGroup rebuilt its hash table from partial-group batches without restoring nullable group-key metadata. When the first merged partial batch only contained non-null ss_customer_sk, the merge hash table was initialized as if the group key had no nulls, and later partial batches carrying the NULL customer group could be dropped.

This PR:

  • serializes keyNullable in the partial-group payload
  • restores nullable key metadata before MergeGroup builds its hash table
  • resets merge-side group-key metadata in Prepare
  • adds a focused unit test for the late-NULL merge order
  • rewrites test/distributed/cases/benchmark/tpcds/01_issue_24208.sql into a focused BVT for this regression

Validation:

  • go test ./pkg/sql/colexec/group -count=1
  • go test ./pkg/sql/plan/function -run 'Test_fixedTypeCastRule2|Test_GetFunctionByName' -count=1
  • mo-tester genrs -i issue_24208
  • mo-tester run -i issue_24208 -t 3
  • local 1G TPC-DS q34 recheck:
    • before fix: grouped pairs = 4726, final rows = 513~517
    • after fix: grouped pairs = 5065, final rows = 471
    • MatrixOne result matches MySQL after the fix

Note:

  • the earlier same-type integer-division change was removed from this PR because it was not the root cause of q34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes type inference for same-type INT/UINT division so that the / operator casts operands to decimal128 (instead of float64), improving precision for boundary comparisons (e.g., ... / ... > 1.2) and addressing issue #24208.

Changes:

  • Update fixed cast rules so same-type integer division uses decimal128 operands.
  • Add unit tests validating the new cast inference and / return type for same-type integer operands.
  • Add a distributed (BVT) SQL repro case + expected result for the boundary-mismatch scenario.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/sql/plan/function/type_check.go Changes fixed cast rules for same-type int*/uint* division to cast operands to decimal128.
pkg/sql/plan/function/function_test.go Adds unit coverage asserting same-type integer / uses decimal128 casts and returns decimal128(38,6).
test/distributed/cases/benchmark/tpcds/01_issue_24208.sql Adds a minimal SQL repro for the boundary precision problem using BIGINT division in a filter.
test/distributed/cases/benchmark/tpcds/01_issue_24208.result Adds the expected output for the new BVT case.

Comment thread pkg/sql/plan/function/function_test.go Resolved
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/L Denotes a PR that changes [500,999] lines labels Apr 27, 2026
@mergify

mergify Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-04-29 02:23 UTC · Rule: main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-04-29 03:21 UTC · at 4d642d02fca86b61aa0f090b2ace7e8642321505 · squash

This pull request spent 58 minutes 24 seconds in the queue, including 58 minutes 8 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

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/bug Something isn't working kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: q34: HAVING COUNT boundary mismatch (MO 519 vs MySQL 471)

4 participants