Repository navigation
fix(aggexec): support YEAR input for variance/stddev aggregates (#30181) - #30365
Conversation
…ixorigin#30181) The statistical-aggregate binder accepts YEAR through its numeric type set, but the executor constructor (makeVarStdDevExec) had no YEAR branch and panicked with "unsupported type 'YEAR' for var/stddev". This made SELECT VAR_POP/STDDEV_* over a YEAR column fail while the same query succeeds in MySQL 8.0. Route T_year to the float64-state executor over the underlying types.MoYear (int16) value, matching how SUM/AVG already handle YEAR. The YEAR numeric value is used, so VAR_POP over years 2020/2021/2022 returns 0.6666666666666666 as in MySQL. Tests: - unit test covering var_pop/var_samp/stddev_pop/stddev_samp for YEAR, resident and distinct modes - BVT coverage including NULL and empty-set handling
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Reviewed head Recommendation: approve from code review, subject to completion of the remaining required CI. No confirmed blocking findings. The new The added unit cases cover all four variance/stddev variants, with and without DISTINCT. The SQL regression also covers the variance alias, NULL input, and an empty result. As a non-blocking follow-up, add YEAR-specific partial-merge and serialization/spill round trips, including all-NULL/singleton groups and YEAR 0000, so future state changes cannot silently regress the newly supported type. Validation: Ordinary review comment only; no formal review-state change. |
|
Follow-up review of latest head The head updated during review. I checked the merge from main: the net four-file PR patch has the same stable patch ID as the previously reviewed Independent local validation now passes:
The previous head's Ubuntu UT job did eventually fail, but its diagnostics show the aggexec package and every The new head's CI is still queued/running, so the earlier green checks must not be treated as a completed run for this merge commit. Please wait for that run and investigate any repeated foreign-key/cluster timeout separately. Keeping the added YEAR merge/serialization edge cases as committed regressions would still be a useful non-blocking follow-up. Ordinary review comment only; no formal approval submitted or source changes pushed. The additional tests were review-only files in an isolated worktree; no full local BVT pass is claimed. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 89d27c6c748d1e7a1ff641f3ed31ff3647625fb3
Assessment: approve
Reviewed all four changed files and affected callers. YEAR dispatch correctly reuses the existing variance/stddev implementation, preserving numeric semantics, state layouts and cleanup without adding per-row work to existing type paths. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Variance tests passed, including all eight new YEAR cases; receipt 1792144092675003105-3.json.
-
Full aggexec package passed, including 64 diagnostic YEAR scenarios covering DISTINCT, modern/legacy state, merge, wire/spill round trips and boundary/NULL/empty/singleton inputs; receipt 1792144160008963370-3.json.
-
Merge-base control reproduced the original unsupported-YEAR panic; receipt 1792144195478918238-3.json. This was an expected baseline failure.
-
Public MySQL-protocol checks passed the new 13-statement SQL block twice, plus aliases, CAST equivalence, boundary values and cleanup; receipt 1792144203332000292-3.json.
-
Frozen exact-head CI records successful required checks. Clean sources, native provenance, diagnostic inputs and receipt/log correspondence were verified in /home/xupeng/.local/state/mo-bot/jobs/88c6328cb9f414a055e90098/attempt-1/evidence-audit.json; final audit receipt 1792144313219555514-4.json.
Limitations:
-
Additional edge tests are retained diagnostic overlays, not committed regressions.
-
Local public validation used an embedded-cluster MySQL endpoint; it was not a full mo-tester run, mixed-version deployment test or MySQL-server comparison.
-
No performance benchmark was needed: existing execution loops and allocation policies are unchanged.
Merge Queue Status
This pull request spent 1 hour 5 minutes 45 seconds in the queue, with no time running CI. ReasonPull request #30365 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #30181
What this PR does / why we need it:
The statistical-aggregate binder accepts
YEARthrough its numerictype set, but the executor constructor (
makeVarStdDevExecinpkg/sql/colexec/aggexec/vardev2.go) had noT_yearbranch andpanicked with
internal error: unsupported type 'YEAR' for var/stddev.So
SELECT VAR_POP(y) FROM tover a YEAR column failed even though thequery is valid and works in MySQL 8.0 (
VAR_POPover years2020/2021/2022 =
0.6666666666666666).This PR routes
T_yearto the float64-state executor over theunderlying
types.MoYear(int16) storage value — the same approachSUM/AVG already use for YEAR — by:
types.MoYearto the value-type unions of thevariance/stddev executor
case types.T_yearbranch tomakeVarStdDevExecThe YEAR numeric value is used (not date-part decomposition), matching
MySQL semantics;
VAR_POP(y)andVAR_POP(CAST(y AS DOUBLE))returnidentical results, including NULL and empty-set handling, and DISTINCT
works via byte-exact payload equality (unit-tested).
Tests
TestVarianceYearResultscovers var_pop / var_samp /stddev_pop / stddev_samp for YEAR in resident and distinct modes
func_aggr_var_popcovering all four aggregates,NULL rows and the empty-set case