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

Rounding issue with casting, such as casting(float4 as int)

    XMLWordPrintableJSON

Details

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

    Description

      #Thu Jun 26 13:57:45 PDT 2014
      git.commit.id.abbrev=3ea8eb5

      For data type float4 (real), we still don't round correctly when casting from float4 to int.

      postgres:
      foodmart=# select c_row, c_float4, cast(c_float4 as int) from data;
      c_row | c_float4 | c_float4
      -----------------------
      1 | 10.5 | 10
      2 | 100.06 | 100
      3 | 10.5 | 10
      4 | 100.006 | 100
      5 | -1.00006 | -1
      6 | 123456 | 123456
      7 | 999999 | 999999
      8 | -999999 | -999999
      9 | 1e-05 | 0
      10 | 0 | 0
      11 | 0.1 | 0
      12 | 0.5 | 0
      13 | 0.6 | 1
      14 | -0.0456 | 0
      15 | -456.678 | -457
      16 | 1203.43 | 1203
      17 | 9999.99 | 10000
      18 | -9999.99 | -10000
      19 | 0.0009 | 0
      20 | 4593.29 | 4593
      21 | 9302.21 | 9302
      22 | 5.832 | 6
      23 | -3920.23 | -3920
      (23 rows)

      drill:
      0: jdbc:drill:schema=dfs> select cast(c_float4 as int) from data;
      ------------

      EXPR$0

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

      10
      100
      10
      100
      -1
      123456
      999999
      -999999
      0
      0
      0
      0
      0
      0
      -456
      1203
      9999
      -9999
      0
      4593
      9302
      5
      -3920

      ------------
      23 rows selected (0.125 seconds)

      Attachments

        1. DRILL-1085.patch
          7 kB
          Mehant Baid

        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: