Uh oh!
There was an error while loading. Please reload this page.
ARROW-14844 [R] Implement decimal256() - #11805
Conversation
romainfrancois
left a comment
There was a problem hiding this comment.
in addition: dragosmg#1
| #' @rdname data-type | ||
| #' @export | ||
| decimal256 <- function(precision, scale) { |
There was a problem hiding this comment.
Perhaps decimal() and decimal256 could call the same function for argument checking, e.g.
check_decimal_args<-function(precision, scale) {
precision<- vec_cast(precision, to= integer())
vec_assert(precision, size=1L)
scale<- vec_cast(scale, to= integer())
vec_assert(scale, size=1L)
list(precision=precision, scale=scale)
}
#' @rdname data-type#' @exportdecimal<-function(precision, scale) {
args<- check_decimal_args(precision, scale)
Decimal128Type__initialize(args$precision, args$scale)
}
#' @rdname data-type#' @exportdecimal256<-function(precision, scale) {
args<- check_decimal_args(precision, scale)
Decimal256Type__initialize(args$precision, args$scale)
}There was a problem hiding this comment.
Great idea! I will implement it.
romainfrancois
commented
Dec 3, 2021
As with library(arrow, warn.conflicts=FALSE)
#> See arrow_info() for available featuresArray$create(c(1, 2), type= decimal(4, 3))
#> Error: NotImplemented: ExtendCreated on 2021-12-03 by the reprex package (v2.0.1.9000) The error comes from this class in template <typename T>
classRPrimitiveConverter<T, enable_if_t<is_decimal_type<T>::value>>
: public PrimitiveConverter<T, RConverter> {
public:
Status Extend(SEXP x, int64_t size, int64_t offset = 0) override {
returnStatus::NotImplemented("Extend");
}
};Maybe we could catch the |
romainfrancois
commented
Dec 3, 2021
Perhaps we could have something like this on the R side: Array$create<-function(x, type=NULL) {
if (!is.null(type)) {
type<- as_type(type)
}
if (inherits(x, "Scalar")) {
out<-x$as_array()
if (!is.null(type)) {
out<-out$cast(type)
}
return(out)
}
tryCatch(
vec_to_Array(x, type),
error=function(cnd) {
if (!is.null(type)) {
# try again and then cast
vec_to_Array(x, NULL)$cast(type)
} else {
signalCondition(cnd)
}
}
)
}So that: library(arrow, warn.conflicts=FALSE)
#> See arrow_info() for available featuresArray$create(c(1, 2), type= decimal(4, 3))
#> Array#> <decimal128(4, 3)>#> [#> 1.000,#> 2.000#> ]Created on 2021-12-03 by the reprex package (v2.0.1.9000) |
dragosmg
commented
Dec 8, 2021
This is outdated. Work on |
@jonkeane & @romainfrancois this is the 2nd attempt at implementing `decimal256()`. First one is #11805Closes#11898 from dragosmg/ARROW-14844_decimal256_take2 Lead-authored-by: Dragos Moldovan-Grünfeld <dragos.mold@gmail.com> Co-authored-by: Dragoș Moldovan-Grünfeld <dragos.mold@gmail.com> Signed-off-by: Jonathan Keane <jkeane@gmail.com>
No description provided.