Skip to content

fix(sql): accept BOOL and ENUM in statistical aggregates - #30223

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/stat-agg-bool-enum-30180
Oct 14, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/stat-agg-bool-enum-30180

Conversation

@iamlinjunhong

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:

What this PR does / why we need it:

VAR_POP, VAR_SAMP, STDDEV_POP, STDDEV_SAMP and their aliases currently reject BOOL and ENUM operands that MySQL accepts in numeric contexts. Resolve BOOL through the existing INT8 cast (0/1) and ENUM through UINT16 (stored ordinal), then reuse the existing statistical aggregate executors. Existing NULL/cardinality semantics and the separate SUM/AVG BOOL SQL-mode gate are preserved.

Regression coverage checks function resolution and result types, ordinary/prepared/window binding, ENUM provenance across projections, and prepared-template immutability. A six-row SQL case verifies independent numeric results, aliases, DISTINCT, grouping, empty/all-NULL/singleton inputs, windows, explicit label conversion, and repeated prepared execution.

Validation on macOS arm64 with Go 1.27.1:

  • Focused registry/planner regression and neighboring compatibility controls passed.
  • Both owning packages (pkg/sql/plan/function, pkg/sql/plan) passed normal unit tests with -count=1.
  • Changed-package gofmt, go vet, and incremental golangci-lint passed.
  • Exact BVT case passed normal mo-tester comparison twice on the same task-owned one-CN instance (31/31 statements each); database teardown was checked after both runs.
  • gpt-6-astra medium design and final overall review recorded locally.

The added per-input integer conversion has the same cost as an explicit cast; no aggregate algorithm, state, storage, or wire format changes. CI remains pending. The issue should remain open for the reporter to verify after merge.

@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 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: d719213dad8be34184ab3772c56967b08b90178c

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: d719213dad8be34184ab3772c56967b08b90178c

Assessment: approve

Reviewed the complete seven-file delta and affected callers. The central resolver correctly reuses existing integer casts and statistical executors, preserving NULL semantics, prepared binding and the separate SUM/AVG BOOL gate. No actionable defects found.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Focused registry and planner tests passed: 17 top-level tests, including 32 runtime boundary cases covering BOOL, ENUM ordinals 0/32768/65535, NULL, DISTINCT and serialized partial-state merge.

  • The same 32 boundary cases failed at type resolution with the exact base resolver, confirming regression coverage.

  • Isolation preflight passed; verified 192 native inputs and 62 retained build artifacts. Diff check passed and source remained unchanged.

  • Commands, source fingerprints, exit receipts and logs reconciled in /home/xupeng/.local/state/mo-bot/jobs/0539424518a895bf91849e4e/attempt-1/evidence-audit.json.

  • Frozen-head CI reports successful Ubuntu unit tests and proxy/pessimistic multi-CN BVT runs.

Limitations:

  • No local SQL-server replay; CI per-case logs and author validation receipts were not supplied.

  • The linked issue's full text was unavailable; its contract was assessed from the frozen PR description.

  • Performance was assessed structurally, without benchmarks: existing inputs incur two additional resolver comparisons; newly supported inputs use ordinary cast vectors.

@mergify mergify Bot added the queued label Oct 14, 2026
@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-14 21:35 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-14 22:04 UTC · at fe9bc9a9c5f49bacd33fe25d2a88400cd2229876

This pull request spent 28 minutes 42 seconds in the queue, with no time running CI.

Reason

Pull request #30223 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.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You 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.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

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
ci — fe9bc9a9 Deployed Oct 14, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

3 participants