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

Wrong number decimals in UNION of AVG

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Won't Fix
    • 1.4.3
    • Icebox
    • ExeMgr
    • 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

            leonid.fedorov Leonid Fedorov
            David.Hall David Hall (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.