Skip to content

fix(agg): preserve decimal variance precision - #29170

Merged
XuPeng-SH merged 3 commits into
mainfrom
codex/issue-28852-temporal-variance
Sep 20, 2026
Merged

XuPeng-SH merged 3 commits into
mainfrom
codex/issue-28852-temporal-variance

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Test and CI

Which issue(s) this PR fixes:

Fixes #28852

What this PR does / why we need it:

Decimal variance and standard-deviation executors accumulate in float64. Their previous final conversion exposed the binary ULP tail as decimal digits, so the issue's DATETIME/TIMESTAMP VAR_POP result became 680202686800.666624 instead of MySQL-compatible 680202686800.666600.

This change converts finite aggregate results through their shortest round-trip decimal representation before scaling to Decimal128. It is deliberately limited to the Decimal variance/stddev finalizer: planner coercion, recurrence, distributed state/wire format, global casts, and float-returning aggregates are unchanged.

Validation includes:

  • exact conversion boundaries, signs, non-finite values, exponent notation, precision overflow, and adjacent-float cases;
  • exact executor results for Decimal64/Decimal128, VAR/STDDEV population/sample, resident/DISTINCT paths;
  • serialized-state restore and merge;
  • the original temporal SQL regression and all twelve existing DECIMAL variance overflow assertions, preserving exact target precision/scale while allowing approximate numeric payload variation;
  • full owning-package tests, go vet, scoped golangci-lint, and build;
  • current rebased code: native/server build and full aggexec package tests passed;
  • normal BVT comparison twice on one fresh instance: 419/419 each (VAR_POP/VARIANCE 242, VAR_SAMP 141, temporal regression 14, cosine boundary 22), with no test schemas left after either run.

The branch includes main through b2f178defd (#29175 cosine regression correction). Current remote SCA/full CI is pending; the earlier revision passed scoped static checks. The follow-up changes only BVT error expectations and retains all executable SQL and successful-result oracles.

GPT-6 Astra medium completed both design review and final overall review; final verdict: PASS with no material findings.

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

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PASS — completed a deep review using GPT-6 Astra / medium of 6e7f923 against b2f178d.

No P0/P1/P2 blockers found. Reviewed decimal conversion boundaries, VAR/STDDEV state and merge/flush paths, error cleanup, and regression oracles. Verified exact-head CI and normal-comparison BVT results: 14/14 temporal, 242/242 VAR_POP, and 141/141 VAR_SAMP. Coverage was not used as a gate.

@XuPeng-SH
XuPeng-SH merged commit 011efc0 into main Sep 20, 2026
7 of 10 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-28852-temporal-variance branch September 20, 2026 23:09

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.

[Compatibility]: temporal VAR_POP differs from MySQL at DECIMAL(24,6) precision

2 participants