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

Decimal multiplication breaks when the precision exceeds 38 even when the actual data is small

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.5.0
    • Execution - Data Types
    • None

    Description

      git.commit.id.abbrev=caa8b78

      Input File Contents :

      111.11|222.22|333.33
      444.44|555.55|666.66
      777.77|888.88|999.99
      

      The below SQL query gives inaccurate results since the precision of the multiplication is 39 (>38):

      select cast(columns[0] as decimal(15,2)) * cast(columns[1] as decimal(15,2)) * cast(columns[2] as decimal(15,2)) val from `decimal_scale.tbl`;
      +------------+
      |     val      |
      +------------+
      | 1000000000 |
      | 0          |
      | 0          |
      +------------+
      

      However the below SQL query succeeds :

       select cast(columns[0] as decimal(5,2)) * cast(columns[1] as decimal(5,2)) * cast(columns[2] as decimal(5,2)) val from `decimal_scale.tbl`;
      +------------+
      |     val      |
      +------------+
      | 8230205.763786 |
      | 164604115.275720 |
      | 691337284.158024 |
      +------------+
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            rkins Rahul Kumar Challapalli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment