Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
[NSE-239] Adopt ARROW-7011 (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhztheplayer authored Apr 12, 2021
1 parent 9dbfc79 commit 7b7bc88
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions native-sql-engine/cpp/src/precompile/gandiva.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@ T round2(T val, int precision = 2) {
}

arrow::Decimal128 castDECIMAL(double val, int32_t precision, int32_t scale) {
double dVal = (double)val;
int charsNeeded = 1 + snprintf(NULL, 0, "%.*f", (int)scale, dVal);
char* buffer = reinterpret_cast<char*>(malloc(charsNeeded));
snprintf(buffer, sizeof(buffer), "%.*f", (int)scale, nextafter(val, val + 0.5));
auto decimal_str = std::string(buffer);
free(buffer);
return arrow::Decimal128::FromString(decimal_str).ValueOrDie();
return arrow::Decimal128::FromReal(val, precision, scale).ValueOrDie();
}

std::string castStringFromDecimal(arrow::Decimal128 val, int32_t scale) {
Expand Down

0 comments on commit 7b7bc88

Please sign in to comment.