You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/04/09 02:01:09 UTC
[doris] 06/12: [Bug](decimal) Fix string to decimal (#18282)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit cb9849747210eda7c668df3cf23e3e6736e8ab33
Author: Gabriel <ga...@gmail.com>
AuthorDate: Mon Apr 3 15:30:48 2023 +0800
[Bug](decimal) Fix string to decimal (#18282)
---
be/src/util/string_parser.hpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/be/src/util/string_parser.hpp b/be/src/util/string_parser.hpp
index 02006b7c7d..4d203a43d6 100644
--- a/be/src/util/string_parser.hpp
+++ b/be/src/util/string_parser.hpp
@@ -646,7 +646,6 @@ inline T StringParser::string_to_decimal(const char* s, int len, int type_precis
}
// Find the number of truncated digits before adjusting the precision for an exponent.
- int truncated_digit_count = precision - type_precision;
if (exponent > scale) {
// Ex: 0.1e3 (which at this point would have precision == 1 and scale == 1), the
// scale must be set to 0 and the value set to 100 which means a precision of 3.
@@ -678,9 +677,6 @@ inline T StringParser::string_to_decimal(const char* s, int len, int type_precis
} else if (UNLIKELY(scale > type_scale)) {
*result = StringParser::PARSE_UNDERFLOW;
int shift = scale - type_scale;
- if (UNLIKELY(truncated_digit_count > 0)) {
- shift -= truncated_digit_count;
- }
if (shift > 0) {
T divisor;
if constexpr (std::is_same_v<T, vectorized::Int128I>) {
@@ -688,14 +684,14 @@ inline T StringParser::string_to_decimal(const char* s, int len, int type_precis
} else {
divisor = get_scale_multiplier<T>(shift);
}
- if (LIKELY(divisor >= 0)) {
+ if (LIKELY(divisor > 0)) {
T remainder = value % divisor;
value /= divisor;
if ((remainder > 0 ? T(remainder) : T(-remainder)) >= (divisor >> 1)) {
value += 1;
}
} else {
- DCHECK(divisor == -1); // //DCHECK_EQ doesn't work with __int128.
+ DCHECK(divisor == -1 || divisor == 0); // //DCHECK_EQ doesn't work with __int128.
value = 0;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org