Repository navigation
fix: support SUM() over boolean expressions for MySQL compatibility - #24625
Conversation
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? |
MySQL coerces booleans to 0/1 in numeric contexts, so SUM(boolean_expr) is a common idiom for counting matching rows. Add T_bool to SumSupportedTypes and register bool->uint64 overload.
The median computation test case previously expected a "bad value [BOOL]" error from SUM(y.val <= x.val). Now that SUM() supports boolean input, update the expected result to the correct median output.
c1afb90 to
06db786
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed from multiple angles: SUM(bool) support is wired consistently across supported types, return type inference, bool-specific fill/fills/merge paths, and registration. The behavior matches MySQL semantics (true->1, false->0), the diff is clean, and I did not find a blocker-level issue in the current changes.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed. Implementation and test coverage for SUM(bool) look good to me.
Merge Queue Status
This pull request spent 55 minutes 40 seconds in the queue, including 54 minutes 53 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #24547
What this PR does / why we need it:
MySQL coerces booleans to 0/1 in numeric contexts, so
SUM(boolean_expr)is a common idiom for counting rows matching a condition (e.g.SUM(status = 'ERROR')for error-rate rollups over agent-trace tables). MatrixOne currently rejects this withbad value [BOOL].Changes:
T_booltoSumSupportedTypesandSumReturnTypeinpkg/sql/plan/function/agg/sum.goaggSumOfBoolFill,aggSumOfBoolFills,aggSumOfBoolMerge) since Go'sbooldoesn't satisfy the genericnumericconstraint used by the existing fill functionsRegisterSum2The pattern follows existing
MIN/MAXbool support (pkg/sql/plan/function/agg/max.go:132).