[ 
https://issues.apache.org/jira/browse/ARROW-6704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Antoine Pitrou resolved ARROW-6704.
-----------------------------------
    Fix Version/s: 1.0.0
       Resolution: Fixed

Issue resolved by pull request 5623
[https://github.com/apache/arrow/pull/5623]

> [C++] Cast from timestamp to higher resolution does not check out of bounds 
> timestamps
> --------------------------------------------------------------------------------------
>
>                 Key: ARROW-6704
>                 URL: https://issues.apache.org/jira/browse/ARROW-6704
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++
>            Reporter: Joris Van den Bossche
>            Assignee: Joris Van den Bossche
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.0.0
>
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> When casting eg {{timestamp('s')}} to {{timestamp('ns')}}, we do not check 
> for out of bounds timestamps, giving "garbage" timestamps in the result:
> {code}
> In [74]: a_np = np.array(["2012-01-01", "2412-01-01"], dtype="datetime64[s]") 
>                                                                               
>                                                        
> In [75]: arr = pa.array(a_np)                                                 
>                                                                               
>                                                        
> In [76]: arr                                                                  
>                                                                               
>                                                        
> Out[76]: 
> <pyarrow.lib.TimestampArray object at 0x7f3d1f07cb88>
> [
>   2012-01-01 00:00:00,
>   2412-01-01 00:00:00
> ]
> In [77]: arr.cast(pa.timestamp('ns'))                                         
>                                                                               
>                                                        
> Out[77]: 
> <pyarrow.lib.TimestampArray object at 0x7f3d1f07cfa8>
> [
>   2012-01-01 00:00:00.000000000,
>   1827-06-13 00:25:26.290448384
> ]
> {code}
> Now, this is the same behaviour as numpy, so not sure we should do this. 
> However, since we have a {{safe=True/False}}, I would expect that for 
> {{safe=True}} we check this and for {{safe=False}} we do not check this.  
> (numpy has a similiar {{casting='safe'}} but also does not raise an error in 
> that case).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to