Skip to content

fix(function): GREATEST/LEAST accept BOOL mixed with numeric or string arguments - #31297

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/least-greatest-bool
Oct 30, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/least-greatest-bool

Conversation

@MatrixAdventurer

@MatrixAdventurer MatrixAdventurer commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Fixes #31293

What this PR does / why we need it:

GREATEST / LEAST rejected a BOOL argument mixed with any other type with bad value [BIGINT BOOL] / [DOUBLE BOOL] / [VARCHAR BOOL]. MySQL treats TRUE/FALSE as 1/0: GREATEST(2, TRUE) is 2, and GREATEST('a', TRUE) is 'a' (string comparison with '1').

Root cause: resolveLeastGreatestType had no rule for BOOL next to another type. BOOL isn't numeric for leastGreatestCommonNumericType / leastGreatestStringMixedType.

Fix: func_builtin_leastgreatest.go +57 adds resolveLeastGreatestMixedBool, which works like the existing ENUM normalization:

Evidence

  • UT least_greatest_bool_test.go: 9 mixed cases × {greatest, least} RED on main (bad value [BIGINT BOOL]), GREEN with the fix, plus a BOOL-only control. All TestLeastGreatest* pass, and so do go test ./pkg/sql/plan/function ./pkg/sql/plan.
  • New BVT function/func_least_greatest_bool.sql: main 6/14, PR 14/14.
  • E2E on a local single node:
query main PR (= MySQL)
greatest(2, true), least(2, true), greatest(true, 0), least(false, 3) bad value [BIGINT BOOL] 2 1 1 0
greatest(1e0, true), least(0.5e0, true) bad value [DOUBLE BOOL] 1 0.5
greatest('a', true), least('a', true) bad value [VARCHAR BOOL] a 1
greatest(d, b), least(f, b) (d=2.5, f=1.5, b=true) bad value [DOUBLE BOOL] 2.5 1
greatest(true, false) 1 1 (unchanged)

Merge Danger

Low. Only calls that used to fail to bind are affected: BOOL mixed with other types. BOOL-only and non-BOOL calls take exactly the same path as before.

本操作由 LW 授权的 Grok Bot 智能体执行。

@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 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 33ece5d547cc0c6b0bd92db1740d251c9ada8937

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: 33ece5d547cc0c6b0bd92db1740d251c9ada8937

Assessment: approve

Mixed-BOOL resolution correctly reuses existing promotion and cast paths, preserves unsigned range and NULL behavior, and leaves BOOL-only calls unchanged. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • 36 focused LEAST/GREATEST tests passed across function and planner packages.

  • Full function-package tests passed; changed Go files are gofmt-clean.

  • Reused frozen exact-head successful UT, SCA, and active BVT-group evidence.

  • Receipts and retained logs reconciled in validation-evidence.json; source unchanged and discussion coverage complete.

Limitations:

  • No local service BVT run; individual CI case logs were unavailable.

  • BOOL-to-DECIMAL remains unsupported, as explicitly assigned to the separate dependency in the linked issue.

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

mergify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

7 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Fri 30 Oct, 12:05 · rule main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue 12:12 · 33ece5d

Reason

Pull request #31297 has been dequeued by @MatrixAdventurer with a dequeue command

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

Times in UTC · dashboard · how the merge queue works

@MatrixAdventurer

Copy link
Copy Markdown
Contributor Author

@Mergifyio dequeue

已获批准(感谢 review),但本 PR 不在本轮授权合并清单内,先移出合并队列,由 LW 确认后再入队。

本操作由 LW 授权的 Grok Bot 智能体执行

@mergify mergify Bot added dequeued and removed queued labels Oct 30, 2026
@MatrixAdventurer

Copy link
Copy Markdown
Contributor Author

@Mergifyio requeue

本操作由 LW 授权的 Grok Bot 智能体执行

@mergify

mergify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

14 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Fri 30 Oct, 12:58 · rule main · triggered by a @mergifyio queue command
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 13:12 · abf2e5d

Reason

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

Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

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

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added queued and removed dequeued labels Oct 30, 2026
@mergify

mergify Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

requeue

☑️ This pull request is already queued

This branch was previously deployed

1 inactive deployment
ci — abf2e5dd Deployed Oct 30, 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.

[Bug]: GREATEST/LEAST reject a BOOL argument mixed with numeric or string arguments

3 participants