Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
ARROW-14844: [R] Implement decimal256()#11898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2957655387ae077ab86fc1253ba3e17401cdf96c167cf85dbc0bd2791cc6b20619a3d66162deec623389e737c1ee9c40bc36f566f9d0b317f8bfacfd476428307195d36b996dea19fd320f054fc4442fb84879af7eb138b068755f1f02407e9a27f9fb1c39a4622e228ec06ed9f9031e6640e8cdb7148dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -187,8 +187,30 @@ Array$create <- function(x, type = NULL) { | ||
| } | ||
| return(out) | ||
| } | ||
| vec_to_Array(x, type) | ||
| if (is.null(type)) { | ||
| return(vec_to_Array(x, type)) | ||
| } | ||
| # when a type is given, try to create a vector of the desired type. If that | ||
| # fails, attempt to cast and if casting is successful, suggest to the user | ||
| # to try casting manually. If the casting fails, return the original error | ||
| # message. | ||
| tryCatch( | ||
| vec_to_Array(x, type), | ||
| error = function(cnd) { | ||
| attempt <- try(vec_to_Array(x, NULL)$cast(type), silent = TRUE) | ||
| abort( | ||
| c(conditionMessage(cnd), | ||
| i = if (!inherits(attempt, "try-error")) { | ||
| "You might want to try casting manually with `Array$create(...)$cast(...)`." | ||
| } | ||
| ) | ||
| ) | ||
| } | ||
dragosmg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ) | ||
| } | ||
| #' @include arrowExports.R | ||
| Array$import_from_c <- ImportArray | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -905,6 +905,7 @@ class Converter_Timestamp : public Converter_Time<value_type, TimestampType> { | ||
| } | ||
| }; | ||
| template <typename Type> | ||
| class Converter_Decimal : public Converter { | ||
| public: | ||
| explicit Converter_Decimal(const std::shared_ptr<ChunkedArray>& chunked_array) | ||
| @@ -919,8 +920,9 @@ class Converter_Decimal : public Converter { | ||
| Status Ingest_some_nulls(SEXP data, const std::shared_ptr<arrow::Array>& array, | ||
| R_xlen_t start, R_xlen_t n, size_t chunk_index) const { | ||
| using DecimalArray = typename TypeTraits<Type>::ArrayType; | ||
| auto p_data = REAL(data) + start; | ||
| const auto& decimals_arr = checked_cast<const arrow::Decimal128Array&>(*array); | ||
| const auto& decimals_arr = checked_cast<const DecimalArray&>(*array); | ||
| auto ingest_one = [&](R_xlen_t i) { | ||
| p_data[i] = std::stod(decimals_arr.FormatValue(i).c_str()); | ||
dragosmg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @@ -1217,7 +1219,10 @@ std::shared_ptr<Converter> Converter::Make( | ||
| } | ||
| case Type::DECIMAL128: | ||
| return std::make_shared<arrow::r::Converter_Decimal>(chunked_array); | ||
| return std::make_shared<arrow::r::Converter_Decimal<Decimal128Type>>(chunked_array); | ||
| case Type::DECIMAL256: | ||
| return std::make_shared<arrow::r::Converter_Decimal<Decimal256Type>>(chunked_array); | ||
| // nested | ||
| case Type::STRUCT: | ||
| @@ -1245,7 +1250,7 @@ std::shared_ptr<Converter> Converter::Make( | ||
| break; | ||
| } | ||
| cpp11::stop("cannot handle Array of type ", type->name().c_str()); | ||
| cpp11::stop("cannot handle Array of type <%s>", type->name().c_str()); | ||
| } | ||
| std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) { | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.