Iurii Gerzhedovich created IGNITE-23023:
-------------------------------------------

             Summary: SQL. Improve result type for AVG function for NUMERIC 
types.
                 Key: IGNITE-23023
                 URL: https://issues.apache.org/jira/browse/IGNITE-23023
             Project: Ignite
          Issue Type: Improvement
          Components: sql
            Reporter: Iurii Gerzhedovich


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 precision bigger 
than the input argument and most databases use extended precision.


{code:java}
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.{code}

Let's extend precision with the following rules:
||Input type||Result type||Minimum precision||
|any exact numeric types:

DECIMAL, BIGINT, INTEGER, SMALLINT, TINYINT|DECIMAL|16|
|any approximate numeric types:
DOUBLE, REAL|DOUBLE| |

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to