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

[C++] Cast from timestamp to higher resolution does not check out of bounds timestamps

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.16.0
    • C++

    Description

      When casting eg timestamp('s') to timestamp('ns'), we do not check for out of bounds timestamps, giving "garbage" timestamps in the result:

      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
      ]
      

      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).

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jorisvandenbossche Joris Van den Bossche
            jorisvandenbossche Joris Van den Bossche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 3.5h
                3.5h

                Slack

                  Issue deployment