Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-3946

Wrong number decimals in UNION of AVG

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.4.3
    • Fix Version/s: None
    • Component/s: ExeMgr
    • Labels:
      None

      Description

      MariaDB [tpch1]> select 'Avg', avg(n_regionkey) from nation;
      ---------------------+

      Avg avg(n_regionkey)

      ---------------------+

      Avg 2.0000

      ---------------------+
      1 row in set (0.025 sec)

      Notice there are four decimal places, which is correct.

      Now see
      MariaDB [tpch1]> select 'Max', max(n_regionkey) from nation
      -> union
      -> select 'Avg', avg(n_regionkey) from nation
      -> ;
      ---------------------+

      Max max(n_regionkey)

      ---------------------+

      Max 4.0000
      Avg 2.0000

      ---------------------+
      2 rows in set (0.023 sec)

      Which puts 4 decimal places for both. Presumably, the MAX (an INT) is promoted to long double.

      When used this way
      select 'Avg', avg(n_regionkey) from nation
      union
      (select n_nationkey,n_name from nation where n_regionkey = 0) order by 1, 2;
      ----------------------+

      Avg avg(n_regionkey)

      ----------------------+

      0 ALGERIA
      14 KENYA
      15 MOROCCO
      16 MOZAMBIQUE
      5 ETHIOPIA
      Avg 2.000000000

      ----------------------+
      6 rows in set (0.026 sec)

      Which gives us the odd number of 9 decimals.

      See working_tpch1_compareLogOnly/qa/DL_union.sql.ref.log.

        Attachments

          Activity

            People

            Assignee:
            David.Hall David Hall
            Reporter:
            David.Hall David Hall
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: