Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-23023

Sql. Improve result type for AVG function for NUMERIC types

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0
    • sql
    • Docs Required

    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

          Activity

            People

              korlov Konstantin Orlov
              jooger Iurii Gerzhedovich
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m