Description
After implementing IGNITE-22988 we should have the type of return value for AVG function the same as the argument for the function. This is in line with the SQL 2016 standard, but at the same time, the standard allows scale bigger than the input argument and most databases use extended scale.
iii) If AVG is specified and DT is exact numeric, then the declared type of the result is an implementation-defined exact numeric type with precision not less than the precision of DT and scale not less than the scale of DT. iv) If DT is approximate numeric, then the declared type of the result is an implementation-defined approximate numeric type with precision not less than the precision of DT. v) If DT is decimal floating-point, then the declared type of the result is the decimal floating-point type with implementation-defined precision not less than the precision of DT.
Let's extend precision with the following rules:
Input type | Result type | Minimum scale |
---|---|---|
any exact numeric types: DECIMAL, BIGINT, INTEGER, SMALLINT, TINYINT |
DECIMAL | 16 |
any approximate numeric types: DOUBLE, REAL |
DOUBLE |
Attachments
Issue Links
- Blocked
-
IGNITE-22988 Sql. Align implementations of average calculation (AVG)
- Resolved
- links to