paleolimbot opened a new pull request, #816:
URL: https://github.com/apache/arrow-nanoarrow/pull/816

   ``` r
   library(nanoarrow)
   
   array <- as_nanoarrow_array(bit64::as.integer64(1:3), schema = 
na_timestamp("s"))
   convert_array(array)
   #> [1] "1970-01-01 00:00:01 UTC" "1970-01-01 00:00:02 UTC"
   #> [3] "1970-01-01 00:00:03 UTC"
   
   array <- as_nanoarrow_array(bit64::as.integer64(1:3), schema = 
na_duration("s"))
   convert_array(array)
   #> Time differences in secs
   #> [1] 1 2 3
   ```
   
   This mirrors what is possible in pyarrow:
   
   ```python
   import numpy as np
   import pyarrow as pa 
   
   storage = np.array([1, 2, 3], np.int64)
   pa.array(storage, pa.timestamp("ns"))
   #> <pyarrow.lib.TimestampArray object at 0x11a681720>
   #> [
   #>   1970-01-01 00:00:00.000000001,
   #>   1970-01-01 00:00:00.000000002,
   #>   1970-01-01 00:00:00.000000003
   #> ]
   pa.array(storage, pa.duration("ns"))
   #> <pyarrow.lib.DurationArray object at 0x10f55b340>
   #> [
   #>   1,
   #>   2,
   #>   3
   #> ]
   ```
   
   Because the default integer type in Python is int64, creating these with 
`[1, 2, 3]` also works; however, if these get constructed from an int32 we get 
a failure. In R our default integer type is int32, so I'm not sure exactly what 
is best there. For now I'll just keep it to int64.
   
   
   Closes #811.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to