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

Sql. Numeric aggregate functions accept VARCHAR types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • sql

    Description

      Numeric aggregate functions accept character string values due to implicit casts added by type coercion:

      SELECT AVG('100')
      > Gets transformed into
      SELECT AVG("100"::DECIMAL(MAX_PREC, MAX_SCALE)) 
      

      Explanation
      This particular cast is added since AVG function uses FamilyOperandTypeChecker that always coerces its arguments if possible (it calls TypeCoercion::builtinFunctionCoercion, which in turn calls TypeCoercion::implicitCast(t1, t2) .

      Expected behaviour
      Aggregate functions that accept only numeric types should be rejected by the validator, when called with arguments of other types.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mzhuravkov Maksim Zhuravkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: