Skip to content

fix: coerce temporal and string variance operands - #28509

Merged
XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
jiangxinmeng1:fix/issue-28229
Sep 11, 2026
Merged

XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
jiangxinmeng1:fix/issue-28229

Conversation

@jiangxinmeng1

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:

issue #28229

What this PR does / why we need it:

  • Updated VAR_POP, VAR_SAMP, STDDEV_POP, and STDDEV_SAMP to support MySQL-compatible numeric
    coercion.

  • String operands are implicitly converted to FLOAT64.

  • Temporal operands (DATE, TIME, DATETIME, and TIMESTAMP) are converted to DECIMAL128.

  • Added regression tests covering VARCHAR, DATE, and DATETIME inputs.

  • Verified remotely with:

    • Full pkg/sql/plan/function test suite
    • go build
    • go vet

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

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

Reviewed exact head 4972d08 against merge base 00faf01.

Re-review: I read the full review/comment/thread history and checked both the increment since 590ebf6 and the complete PR diff. The prior blocker is closed: TIME/DATETIME/TIMESTAMP now retain their declared fractional scale when coerced to DECIMAL128, so variance/stddev no longer silently truncate fractional temporal values before aggregation. The aliases resolve to the same aggregate IDs, so they share the corrected type path.

Validation on this exact head:

  • make thirdparties && make -C cgo
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/sql/plan/function
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race -run Test(MySQLNumericAggTypeCheck|VarianceAggregateTypeCheck) -count=1 ./pkg/sql/plan/function

I found no remaining blocking issue.

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

Re-reviewed exact head c0941cb against base a6a493a, including both requested-changes reviews and the intervening approval. No concrete blocker remains.

The prior fractional-temporal loss is fixed: TIME/DATETIME/TIMESTAMP now retain their declared scale in DECIMAL128(38, scale), while DATE remains scale 0. The cast no longer rescales the TIME(6) 0.1/0.3 counterexample to zero. Resolver tests cover scales 1–6 for all four aggregates, and public SQL oracles cover positive/negative TIME, fractional DATETIME/TIMESTAMP, NULL neighbors, grouped results and prepared execution. Existing numeric types remain unchanged; strings use the established FLOAT64 conversion/warning path. This PR changes operand lowering, not aggregate IDs, accumulation/merge state or serialization; the existing numeric variance executors and protocol checks continue to own those contracts.

Also reviewed the additional logservice allocator mutex change in the current full diff rather than treating it as out of scope. Next/Set/Capacity/restore-generation discard each lock only local field accesses, do not call one another or hold the mutex across RPC, and Set's existing panic releases via defer. The change does not claim to make multi-method refill sequences atomic or solve duplicate HAKeeper drivers; no new deadlock or correctness regression found in this bounded locking change.

Evidence: full current diff/history and current cast/registration/allocator consumers plus test assertions. Earlier exact-head native function-suite/race evidence and the PR's remote build/vet report are historical/author evidence, not fresh execution at this rebased head. No new UT/BVT, live distributed SQL, upgrade or benchmark run is claimed; a grouped SQL case alone is not proof of multi-CN execution. CI was not awaited; exact head/base rechecked before submission.

@mergify

mergify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-11 08:02 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-09-11 08:02 UTC · at c0941cbe33f6c146e0306c928c173c60122e7cdf

This pull request spent 9 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/entrypoint.yaml without workflows permission

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

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

@mergify

mergify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-11 08:03 UTC · Rule: main · triggered by @XuPeng-SH with the merge queue checkbox
  • 🚫 Left the queue — 2026-09-11 08:03 UTC · at c0941cbe33f6c146e0306c928c173c60122e7cdf

This pull request spent 23 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/entrypoint.yaml without workflows permission

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

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

  • Requeue this pull request

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 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants