Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-4915

Unbounded DECIMAL casts from floating point to decimal trigger undefined behavior

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Impala 2.9.0
    • Fix Version/s: Impala 2.9.0
    • Component/s: Backend
    • Labels:
      None

      Description

      Here's an example of using Impala as an ASCII art generator:

      [localhost:21000] > select power(2, 1023) * 100;
      Query: select power(2, 1023) * 100
      Query submitted at: 2017-02-11 02:58:50 (Coordinator: http://impala-dev:25000)
      Query progress can be monitored at: http://impala-dev:25000/query_plan?query_id=2346bde04782aabd:3466c05900000000
      +----------------------+
      | power(2, 1023) * 100 |
      +----------------------+
      | Infinity             |
      +----------------------+
      Fetched 1 row(s) in 0.01s
      [localhost:21000] > select cast(power(2, 1023) * 100 AS decimal(10,10));
      Query: select cast(power(2, 1023) * 100 AS decimal(10,10))
      Query submitted at: 2017-02-11 02:59:20 (Coordinator: http://impala-dev:25000)
      Query progress can be monitored at: http://impala-dev:25000/query_plan?query_id=de46ef0a381bc968:66f76aa600000000
      +----------------------------------------------+
      | cast(power(2, 1023) * 100 as decimal(10,10)) |
      +----------------------------------------------+
      | --.*(+,))+(0(                                |
      +----------------------------------------------+
      Fetched 1 row(s) in 0.01s
      [localhost:21000] > set disable_codegen=1;
      DISABLE_CODEGEN set to 1
      [localhost:21000] > select cast(power(2, 1023) * 100 AS decimal(10,10));
      Query: select cast(power(2, 1023) * 100 AS decimal(10,10))
      Query submitted at: 2017-02-11 03:00:00 (Coordinator: http://impala-dev:25000)
      Query progress can be monitored at: http://impala-dev:25000/query_plan?query_id=b64823307d95c477:5d8b586b00000000
      +----------------------------------------------+
      | cast(power(2, 1023) * 100 as decimal(10,10)) |
      +----------------------------------------------+
      | --.*(+,))+(0(                                |
      +----------------------------------------------+
      Fetched 1 row(s) in 0.01s
      [localhost:21000] > set decimal_v2=1;
      DECIMAL_V2 set to 1
      [localhost:21000] > select cast(power(2, 1023) * 100 AS decimal(10,10));
      Query: select cast(power(2, 1023) * 100 AS decimal(10,10))
      Query submitted at: 2017-02-11 03:00:34 (Coordinator: http://impala-dev:25000)
      Query progress can be monitored at: http://impala-dev:25000/query_plan?query_id=b24376cb151d7203:35baf9b300000000
      +----------------------------------------------+
      | cast(power(2, 1023) * 100 as decimal(10,10)) |
      +----------------------------------------------+
      | --.*(+,))+(0(                                |
      +----------------------------------------------+
      Fetched 1 row(s) in 0.01s
      

        Attachments

          Activity

            People

            • Assignee:
              zamsden Zach Amsden
              Reporter:
              zamsden_impala_ad21 Zachary
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: