Skip to content

Commit

Permalink
[NSE-239] Adopt ARROW-7011 (oap-project#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhztheplayer authored and zhouyuan committed Apr 15, 2021
1 parent 097fc6f commit 254e6dc
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 254e6dc

Please sign in to comment.