fix(function,plan): GREATEST/LEAST numeric promotion (#25145) and ambiguous-column typo (#25146) - #25168
Merged
fengttt merged 4 commits intoJun 29, 2026
Conversation
…origin#25145) GREATEST/LEAST rejected mixed numeric arguments (e.g. BIGINT + DOUBLE or BIGINT + DECIMAL) with "invalid argument ... bad value", forcing users to wrap every argument in an explicit CAST. MySQL promotes such arguments to a common numeric type and compares on it. leastGreatestCheck now keeps the existing fast path when all non-NULL arguments share the same type, and otherwise derives a common numeric type and requests an implicit cast of every argument to it: - any floating-point operand -> DOUBLE - any DECIMAL operand -> DECIMAL widened to hold every operand (DECIMAL128/256, falling back to DOUBLE only if it would exceed DECIMAL256) - integer operands -> narrowest integer that holds them all; signed+unsigned that cannot fit INT64 widen to DECIMAL128 to stay lossless Non-numeric arguments that do not already match are still rejected. The executor switches gain a DECIMAL256 branch so a promoted DECIMAL256 compares instead of hitting the unreachable-code panic. Adds a unit test for the promotion matrix and a BVT case (function/greatest_least_numeric) covering the issue's reproductions, aggregate-vs-aggregate comparisons, NULL handling, and per-row mixed columns. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…atrixorigin#25146) The ambiguous-column-reference error (code 20301) raised after a JOIN misspelled "ambiguous" as "ambiguouse". The typo looks unprofessional in user-facing tools and breaks naive error-pattern matching that searches for "ambiguous". Fix the message in bind_context.go and update the four BVT result files that assert it (dtype/varchar, view/alter_view, dml/select/order_by_clause, window/window). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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? |
…ixorigin#25145) The Coverage CI gate flagged uncovered lines in the GREATEST/LEAST numeric promotion code. Add unit and BVT coverage for the branches the existing tests did not reach: - TestLeastGreatestCheck: all-unsigned width promotion, BIT operands, DECIMAL256 seed, mixed-Oid decimals, and the leading-non-numeric reject path. - TestLeastGreatestWidthHelpers: every branch of signedTypeForWidth / unsignedTypeForWidth. - TestLeastGreatestCommonNumericType: drives the helper directly to hit the all-signed/all-unsigned paths, BIT, the DECIMAL256 seed, and the DECIMAL-precision-overflow fallback to DOUBLE. - TestLeastGreatestDecimal256: exercises the new DECIMAL256 branch of the leastFn/greatestFn executors. These bring leastGreatestCheck, leastGreatestCommonNumericType, signedTypeForWidth and unsignedTypeForWidth to 100% and cover the new DECIMAL256 executor cases. BVT function/greatest_least_numeric gains unsigned-only width promotion, signed+unsigned overflow to DECIMAL128, BIT+integer, mixed-scale DECIMAL128, and DECIMAL256 result cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
heni02
approved these changes
Jun 26, 2026
ouyuanning
approved these changes
Jun 27, 2026
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #25145
issue #25146
What this PR does / why we need it:
Two independent bugs from the same investigation surface.
#25145 — GREATEST / LEAST reject implicit numeric promotion
GREATEST/LEASTrejected mixed numeric arguments (e.g.GREATEST(1, 2.0),GREATEST(BIGINT, DOUBLE),GREATEST(COUNT(*), AVG(x))) withinvalid argument ... bad value, because the type checker required everynon-NULL argument to share the exact same type. MySQL promotes such arguments
to a common numeric type and compares on it.
leastGreatestChecknow keeps the existing fast path when all non-NULLarguments already share the same type, and otherwise derives a common numeric
type and requests an implicit cast of every argument to it (via
newCheckResultWithCast):DOUBLEDECIMALoperand →DECIMALwidened to hold every operand(
DECIMAL128/256, falling back toDOUBLEonly beyondDECIMAL256)that cannot fit
INT64widen toDECIMAL128to stay losslessNon-numeric arguments that do not already match are still rejected. The
executor switches gain a
DECIMAL256branch so a promotedDECIMAL256compares instead of hitting the unreachable-code panic.
#25146 — typo "ambiguouse" → "ambiguous"
The ambiguous-column-reference error (code 20301) raised after a JOIN
misspelled "ambiguous". Fixed the message in
bind_context.goand the fourBVT result files that assert it.
Tests
TestLeastGreatestCheckcovering the promotion matrix; existingTestLeast/TestGreateststill pass.function/greatest_least_numeric(27 statements) covering theissue reproductions, aggregate-vs-aggregate comparisons, NULL handling, and
per-row mixed columns.
function/builtin(247), and the four [Bug]: Typo "ambiguouse" → "ambiguous" in column-reference error message #25146-affected BVT cases(
dtype/varchar,view/alter_view,dml/select/order_by_clause,window/window) all pass.🤖 Generated with Claude Code