apache / apache/arrow

[Python] Strange decimal cast when allow_decimal_truncate=True

Open
#44,356 0 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

I'm using the python pyarrow module and running into this strange behavior when casting strings into a decimal:

```py
pyarrow.compute.cast(
pyarrow.array(['0.9999999999999999999999999999999999999999999999999999999999999999999999999']),
options=pyarrow.compute.CastOptions(
target_type=pyarrow.decimal128(38, 19),
allow_decimal_truncate=True
)
)

""" Returns:

[
-3711.3482369388076293398
]
"""
```

Is this behavior expected?

Version: `pyarrow==17.0.0`

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.