Antoine Pitrou created ARROW-8567: ------------------------------------- Summary: [Python] pa.array() sometimes ignore "safe=False" Key: ARROW-8567 URL: https://issues.apache.org/jira/browse/ARROW-8567 Project: Apache Arrow Issue Type: Bug Components: Python Affects Versions: 0.17.0 Reporter: Antoine Pitrou
Generally, {{pa.array(data).cast(sometype, safe=...)}} is equivalent to {{pa.array(data, sometype, safe=...)}}. Consider the following: {code:python} >>> pa.array([Decimal('12.34')]).cast(pa.int32(), safe=False) >>> >>> <pyarrow.lib.Int32Array object at 0x7efbbd1556e0> [ 12 ] >>> pa.array([Decimal('12.34')], pa.int32(), safe=False) >>> >>> <pyarrow.lib.Int32Array object at 0x7efbbd13dad0> [ 12 ] {code} However, that is not always the case: {code:python} >>> pa.array([Decimal('1234')]).cast(pa.int8(), safe=False) >>> >>> <pyarrow.lib.Int8Array object at 0x7efbbd18e4b0> [ -46 ] >>> pa.array([Decimal('1234')], pa.int8(), safe=False) >>> >>> Traceback (most recent call last): ... ArrowInvalid: Value 1234 too large to fit in C integer type {code} I don't think this is very important: first because you can call cast() directly, second because the results are unusable anyway. -- This message was sent by Atlassian Jira (v8.3.4#803005)