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

Casting numeric value that does not fit in integer data type produces incorrect result

    XMLWordPrintableJSON

Details

    Description

      t1.json

      { "a1": 1 ,    "b1" : 1}
      { "a1": 2 ,    "b1" : 1}
      { "a1": 2 ,    "b1" : 2}
      { "a1": 3 ,    "b1" : 2}
      { "a1": 5000147483647 , "b1" : 3}
      

      We should throw an error, this is technically data corruption.

      0: jdbc:drill:schema=dfs> select cast(a1 as integer) from `t1.json`;
      +------------+
      |   EXPR$0   |
      +------------+
      | 1          |
      | 2          |
      | 2          |
      | 3          |
      | 805551103  |
      +------------+
      5 rows selected (0.074 seconds)
      
      0: jdbc:drill:schema=dfs> select cast(2147483648 as integer) from `t1.json`;
      +------------+
      |   EXPR$0   |
      +------------+
      | -2147483648 |
      | -2147483648 |
      | -2147483648 |
      | -2147483648 |
      | -2147483648 |
      +------------+
      5 rows selected (0.076 seconds)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              vicky Victoria Markman
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: