Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-999 Casting (legally) to decimal is broken.
  3. IMPALA-1000

Casting all integer types to a legal Decimal is broken.

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Impala 1.4
    • Impala 1.4
    • None

    Description

      Casting from an integer type to a legal Decimal type breaks down frequently.

      I've used the following constraints to define what a legal decimal is:

      smallint: 5 <= precision <= 38 && precision - scale >= 5
      int: 10 <= precision <= 38 && precision - scale >= 10
      bigint: 19 <= precision <= 38 && precision - scale >= 19

      Example with smallint:

      [localhost:21000] > select cast(-26659 as Decimal(27,18));
      Query: select cast(-26659 as Decimal(27,18))
      +--------------------------------+
      | cast(-26659 as decimal(27,18)) |
      +--------------------------------+
      | -3.454813489697914880          |
      +--------------------------------+
      Returned 1 row(s) in 0.18s
      [localhost:21000] > select cast(-32130 as Decimal(36,29));
      Query: select cast(-32130 as Decimal(36,29))
      +----------------------------------+
      | cast(-32130 as decimal(36,29))   |
      +----------------------------------+
      | -0.00000000005300179331568369664 |
      +----------------------------------+
      

      Attachments

        Activity

          People

            nong_impala_60e1 Nong Li
            ishaan Ishaan Joshi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: