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

   Implements conversion from R to Decimal128/256 in such a way that it works 
with `Array$create()`.
   
   Before this PR:
   
   ``` r
   library(arrow, warn.conflicts = FALSE)
   #> Some features are not enabled in this build of Arrow. Run `arrow_info()` 
for more information.
   Array$create(1)$cast(decimal(10, 2))
   #> Array
   #> <decimal128(10, 2)>
   #> [
   #>   1.00
   #> ]
   
   Array$create(1, type = decimal128(10, 2))
   #> Error in `value[[3L]]()`:
   #> ! NotImplemented: Extend
   #> ℹ You might want to try casting manually with 
`Array$create(...)$cast(...)`.
   
   #> Backtrace:
   #>     ▆
   #>  1. └─Array$create(1, type = decimal128(10, 2))
   #>  2.   └─base::tryCatch(...) at r/R/array.R:198:2
   #>  3.     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
   #>  4.       └─base (local) tryCatchOne(expr, names, parentenv, 
handlers[[1L]])
   #>  5.         └─value[[3L]](cond)
   #>  6.           └─rlang::abort(...) at r/R/array.R:202:6
   Array$create(1, type = decimal256(10, 2))
   #> Error in `value[[3L]]()`:
   #> ! NotImplemented: Extend
   #> ℹ You might want to try casting manually with 
`Array$create(...)$cast(...)`.
   
   #> Backtrace:
   #>     ▆
   #>  1. └─Array$create(1, type = decimal256(10, 2))
   #>  2.   └─base::tryCatch(...) at r/R/array.R:198:2
   #>  3.     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
   #>  4.       └─base (local) tryCatchOne(expr, names, parentenv, 
handlers[[1L]])
   #>  5.         └─value[[3L]](cond)
   #>  6.           └─rlang::abort(...) at r/R/array.R:202:6
   ```
   
   <sup>Created on 2023-01-05 with [reprex 
v2.0.2](https://reprex.tidyverse.org)</sup>
   
   After this PR:
   
   ``` r
   library(arrow, warn.conflicts = FALSE)
   #> Some features are not enabled in this build of Arrow. Run `arrow_info()` 
for more information.
   Array$create(1)$cast(decimal(10, 2))
   #> Array
   #> <decimal128(10, 2)>
   #> [
   #>   1.00
   #> ]
   
   Array$create(1, type = decimal128(10, 2))
   #> Array
   #> <decimal128(10, 2)>
   #> [
   #>   1.00
   #> ]
   Array$create(1, type = decimal256(10, 2))
   #> Array
   #> <decimal256(10, 2)>
   #> [
   #>   1.00
   #> ]
   ```
   
   <sup>Created on 2023-01-05 with [reprex 
v2.0.2](https://reprex.tidyverse.org)</sup>
   
   TODO: test!


-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to