You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Apache Arrow JIRA Bot (Jira)" <ji...@apache.org> on 2022/12/05 17:52:00 UTC
[jira] [Assigned] (ARROW-8567) [Python] pa.array() sometimes ignore "safe=False"
[ https://issues.apache.org/jira/browse/ARROW-8567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Apache Arrow JIRA Bot reassigned ARROW-8567:
--------------------------------------------
Assignee: (was: Shoichi Kagawa)
> [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
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> 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.20.10#820010)