Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-2387

[Python] negative decimal values get spurious rescaling error

    Details

      Description

      $ python
      Python 2.7.12 (default, Nov 20 2017, 18:23:56)
      [GCC 5.4.0 20160609] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import pyarrow as pa, decimal
      >>> one = decimal.Decimal('1.000000')
      >>> neg_one = decimal.Decimal('-1.000000')
      >>> pa.array([one], pa.decimal128(24, 12))
      <pyarrow.lib.Decimal128Array object at 0x7f7f5ae85cb0>
      [
      Decimal('1.000000000000')
      ]
      >>> pa.array([neg_one], pa.decimal128(24, 12))
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "array.pxi", line 181, in pyarrow.lib.array
      File "array.pxi", line 36, in pyarrow.lib._sequence_to_array
      File "error.pxi", line 77, in pyarrow.lib.check_status
      pyarrow.lib.ArrowInvalid: Rescaling decimal value -1000000.000000 from original scale of 6 to new scale of 12 would cause data loss
      >>> pa.__version__
      '0.9.0'
      
      

      not only is the error spurious, the decimal value has been multiplied by one million (i.e. 10 ** 6 and 6 is the difference in scales, but this is still pretty strange to me).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cpcloud Phillip Cloud
                Reporter:
                ben w ben w
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: