You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The result type for SUM aggregations in go-mysql-server does not match MySQL's. Even though the actual SumBuffer that performs the computation internally uses either float64 or Decimal, the type for the resulting column in the planned schema defaults to the type of the underlying column.
As an example: in MySQL, summing a column of INT (i.e. int32) results in a DECIMAL result for the output row. This is the same when summing any other integral type, regardless of whether the type has overflowed or not. In go-mysql-server, summing a column of INT returns INT. In fact, summing any integral type returns the same integral type.
The general rule for MySQL types in SUMs is as follows:
Any accurate numeric type (e.g. INT, BIGINT, SMALLINT, TINYINT, DECIMAL, etc) sums into DECIMAL.
Any approximate numeric type (e.g. FLOAT, DOUBLE) sums into DOUBLE.
Would you be interested on a PR to mimic this behavior much more closely?
The text was updated successfully, but these errors were encountered:
As discussed in #1476 (comment) --
The result type for
SUM
aggregations ingo-mysql-server
does not match MySQL's. Even though the actualSumBuffer
that performs the computation internally uses eitherfloat64
orDecimal
, the type for the resulting column in the planned schema defaults to the type of the underlying column.As an example: in MySQL, summing a column of
INT
(i.e.int32
) results in aDECIMAL
result for the output row. This is the same when summing any other integral type, regardless of whether the type has overflowed or not. Ingo-mysql-server
, summing a column ofINT
returnsINT
. In fact, summing any integral type returns the same integral type.The general rule for MySQL types in
SUM
s is as follows:INT
,BIGINT
,SMALLINT
,TINYINT
,DECIMAL
, etc) sums intoDECIMAL
.FLOAT
,DOUBLE
) sums intoDOUBLE
.Would you be interested on a PR to mimic this behavior much more closely?
The text was updated successfully, but these errors were encountered: