Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-861

sum(decimal38) gives wrong result, even without overflowing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.4.0
    • Functions - Drill
    • None

    Description

      #Wed May 28 17:19:59 PDT 2014
      git.commit.id.abbrev=c8a08c3

      sum over decimal38 type of data gives wrong result. this is without encounter overflowing.

      I have the following data in a decimal38 column:

      0: jdbc:drill:schema=dfs> select cast(c_decimal38 as decimal(38,14)) from data where c_row <= 14;
      ------------

      EXPR$0

      ------------

      0E-14
      1.00000000000000
      123456789.00000000000000
      999999999.00000000000000
      -999999999.00000000000000
      1.000000E-8
      -1.000000E-8
      12345.67890000000000
      123456789.12345678900000
      999999999999999999.00000000000000
      -999999999999999999.00000000000000
      0E-14
      0E-14
      12345678901234.12345678901234

      ------------
      14 rows selected (0.288 seconds)

      The sum of the columns gives the following wrong number:

      0: jdbc:drill:schema=dfs> select sum(cast(c_decimal38 as decimal(38,14))) from data where c_row <= 14;
      ------------

      EXPR$0

      ------------

      1.2345925827186123E13

      The correct number should be (from postgres, I also hand calculated):

      foodmart=# select sum(cast(c_decimal38 as decimal(38,14))) from data where c_row <= 14;
      sum
      -------------------------------
      12345925827158.92581357801234

      Attachments

        1. DRILL-861.patch
          33 kB
          Mehant Baid

        Issue Links

          Activity

            People

              DrillCommitter DrillCommitter
              cchang@maprtech.com Chun Chang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: