This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new dab4c12a2e  [Fix](decimal) fix decimal precision (#22364) (#22878)
dab4c12a2e is described below

commit dab4c12a2e863e92e334ac8636c90c7435e6a3ed
Author: amory <[email protected]>
AuthorDate: Fri Aug 11 17:53:40 2023 +0800

     [Fix](decimal) fix decimal precision (#22364) (#22878)
---
 be/src/exec/text_converter.cpp                     |  16 ++-
 be/src/olap/predicate_creator.h                    |   2 +-
 be/src/olap/types.h                                |  10 +-
 be/src/runtime/decimalv2_value.cpp                 |   4 +-
 be/src/util/string_parser.hpp                      | 143 ++++++++++++++-------
 be/src/vec/data_types/data_type_decimal.cpp        |  12 +-
 .../vec/data_types/serde/data_type_decimal_serde.h |  16 +++
 be/src/vec/functions/function_cast.h               |  19 ++-
 be/src/vec/io/io_helper.h                          |  14 +-
 .../serde/data_type_serde_arrow_test.cpp           |   6 +-
 10 files changed, 167 insertions(+), 75 deletions(-)

diff --git a/be/src/exec/text_converter.cpp b/be/src/exec/text_converter.cpp
index 90438dc05c..5cfa078fb8 100644
--- a/be/src/exec/text_converter.cpp
+++ b/be/src/exec/text_converter.cpp
@@ -243,7 +243,7 @@ bool TextConverter::write_vec_column(const SlotDescriptor* 
slot_desc,
     }
     case TYPE_DECIMAL32: {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
-        int32_t value = StringParser::string_to_decimal<int32_t>(
+        int32_t value = StringParser::string_to_decimal<TYPE_DECIMAL32, 
int32_t>(
                 data, len, slot_desc->type().precision, 
slot_desc->type().scale, &result);
         if (result != StringParser::PARSE_SUCCESS) {
             parse_result = StringParser::PARSE_FAILURE;
@@ -256,7 +256,7 @@ bool TextConverter::write_vec_column(const SlotDescriptor* 
slot_desc,
     }
     case TYPE_DECIMAL64: {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
-        int64_t value = StringParser::string_to_decimal<int64_t>(
+        int64_t value = StringParser::string_to_decimal<TYPE_DECIMAL64, 
int64_t>(
                 data, len, slot_desc->type().precision, 
slot_desc->type().scale, &result);
         if (result != StringParser::PARSE_SUCCESS) {
             parse_result = StringParser::PARSE_FAILURE;
@@ -269,8 +269,9 @@ bool TextConverter::write_vec_column(const SlotDescriptor* 
slot_desc,
     }
     case TYPE_DECIMAL128I: {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
-        vectorized::Int128 value = 
StringParser::string_to_decimal<vectorized::Int128>(
-                data, len, slot_desc->type().precision, 
slot_desc->type().scale, &result);
+        vectorized::Int128 value =
+                StringParser::string_to_decimal<TYPE_DECIMAL128I, 
vectorized::Int128>(
+                        data, len, slot_desc->type().precision, 
slot_desc->type().scale, &result);
         if (result != StringParser::PARSE_SUCCESS) {
             parse_result = StringParser::PARSE_FAILURE;
             break;
@@ -410,7 +411,7 @@ bool TextConverter::write_vec_column(const SlotDescriptor* 
slot_desc,
                     }
                     case TYPE_DECIMAL32: {
                         StringParser::ParseResult result = 
StringParser::PARSE_SUCCESS;
-                        int32_t value = 
StringParser::string_to_decimal<int32_t>(
+                        int32_t value = 
StringParser::string_to_decimal<TYPE_DECIMAL32, int32_t>(
                                 data + fr, i - fr, Sub_type.precision, 
Sub_type.scale, &result);
                         if (result != StringParser::PARSE_SUCCESS) {
                             local_parse_result = StringParser::PARSE_FAILURE;
@@ -421,7 +422,7 @@ bool TextConverter::write_vec_column(const SlotDescriptor* 
slot_desc,
                     }
                     case TYPE_DECIMAL64: {
                         StringParser::ParseResult result = 
StringParser::PARSE_SUCCESS;
-                        int64_t value = 
StringParser::string_to_decimal<int64_t>(
+                        int64_t value = 
StringParser::string_to_decimal<TYPE_DECIMAL64, int64_t>(
                                 data + fr, i - fr, Sub_type.precision, 
Sub_type.scale, &result);
                         if (result != StringParser::PARSE_SUCCESS) {
                             local_parse_result = StringParser::PARSE_FAILURE;
@@ -433,7 +434,8 @@ bool TextConverter::write_vec_column(const SlotDescriptor* 
slot_desc,
                     case TYPE_DECIMAL128I: {
                         StringParser::ParseResult result = 
StringParser::PARSE_SUCCESS;
                         vectorized::Int128 value =
-                                
StringParser::string_to_decimal<vectorized::Int128>(
+                                
StringParser::string_to_decimal<TYPE_DECIMAL128I,
+                                                                
vectorized::Int128>(
                                         data + fr, i - fr, Sub_type.precision, 
Sub_type.scale,
                                         &result);
                         if (result != StringParser::PARSE_SUCCESS) {
diff --git a/be/src/olap/predicate_creator.h b/be/src/olap/predicate_creator.h
index bd30d32d43..93702ac101 100644
--- a/be/src/olap/predicate_creator.h
+++ b/be/src/olap/predicate_creator.h
@@ -96,7 +96,7 @@ private:
     static CppType convert(const TabletColumn& column, const std::string& 
condition) {
         StringParser::ParseResult result = 
StringParser::ParseResult::PARSE_SUCCESS;
         // return CppType value cast from int128_t
-        return StringParser::string_to_decimal<int128_t>(
+        return StringParser::string_to_decimal<Type, int128_t>(
                 condition.data(), condition.size(), column.precision(), 
column.frac(), &result);
     }
 };
diff --git a/be/src/olap/types.h b/be/src/olap/types.h
index 1c85cd74fe..edd925ea98 100644
--- a/be/src/olap/types.h
+++ b/be/src/olap/types.h
@@ -1027,8 +1027,8 @@ struct 
FieldTypeTraits<FieldType::OLAP_FIELD_TYPE_DECIMAL32>
     static Status from_string(void* buf, const std::string& scan_key, const 
int precision,
                               const int scale) {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
-        int32_t value = 
StringParser::string_to_decimal<int32_t>(scan_key.c_str(), scan_key.size(),
-                                                                 9, scale, 
&result);
+        int32_t value = StringParser::string_to_decimal<TYPE_DECIMAL32, 
int32_t>(
+                scan_key.c_str(), scan_key.size(), 9, scale, &result);
 
         if (result == StringParser::PARSE_FAILURE) {
             return Status::Error<ErrorCode::INVALID_ARGUMENT>(
@@ -1053,8 +1053,8 @@ struct 
FieldTypeTraits<FieldType::OLAP_FIELD_TYPE_DECIMAL64>
     static Status from_string(void* buf, const std::string& scan_key, const 
int precision,
                               const int scale) {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
-        int64_t value = 
StringParser::string_to_decimal<int64_t>(scan_key.c_str(), scan_key.size(),
-                                                                 18, scale, 
&result);
+        int64_t value = StringParser::string_to_decimal<TYPE_DECIMAL64, 
int64_t>(
+                scan_key.c_str(), scan_key.size(), 18, scale, &result);
         if (result == StringParser::PARSE_FAILURE) {
             return Status::Error<ErrorCode::INVALID_ARGUMENT>(
                     "FieldTypeTraits<OLAP_FIELD_TYPE_DECIMAL64>::from_string 
meet PARSE_FAILURE");
@@ -1078,7 +1078,7 @@ struct 
FieldTypeTraits<FieldType::OLAP_FIELD_TYPE_DECIMAL128I>
     static Status from_string(void* buf, const std::string& scan_key, const 
int precision,
                               const int scale) {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
-        int128_t value = StringParser::string_to_decimal<int128_t>(
+        int128_t value = StringParser::string_to_decimal<TYPE_DECIMAL128I, 
int128_t>(
                 scan_key.c_str(), scan_key.size(), 38, scale, &result);
         if (result == StringParser::PARSE_FAILURE) {
             return Status::Error<ErrorCode::INVALID_ARGUMENT>(
diff --git a/be/src/runtime/decimalv2_value.cpp 
b/be/src/runtime/decimalv2_value.cpp
index 3dc357906d..ca50b2d643 100644
--- a/be/src/runtime/decimalv2_value.cpp
+++ b/be/src/runtime/decimalv2_value.cpp
@@ -356,8 +356,8 @@ int DecimalV2Value::parse_from_str(const char* decimal_str, 
int32_t length) {
     int32_t error = E_DEC_OK;
     StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
 
-    _value = StringParser::string_to_decimal<__int128>(decimal_str, length, 
PRECISION, SCALE,
-                                                       &result);
+    _value = StringParser::string_to_decimal<TYPE_DECIMALV2, 
__int128>(decimal_str, length,
+                                                                       
PRECISION, SCALE, &result);
     if (!config::allow_invalid_decimalv2_literal && result != 
StringParser::PARSE_SUCCESS) {
         error = E_DEC_BAD_NUM;
     } else if (config::allow_invalid_decimalv2_literal && result == 
StringParser::PARSE_FAILURE) {
diff --git a/be/src/util/string_parser.hpp b/be/src/util/string_parser.hpp
index fba35768b5..a59d6bf7de 100644
--- a/be/src/util/string_parser.hpp
+++ b/be/src/util/string_parser.hpp
@@ -158,7 +158,7 @@ public:
         return string_to_bool_internal(s + i, len - i, result);
     }
 
-    template <typename T>
+    template <PrimitiveType P, typename T>
     static inline T string_to_decimal(const char* s, int len, int 
type_precision, int type_scale,
                                       ParseResult* result);
 
@@ -568,7 +568,7 @@ inline int 
StringParser::StringParseTraits<__int128>::max_ascii_len() {
     return 39;
 }
 
-template <typename T>
+template <PrimitiveType P, typename T>
 T StringParser::string_to_decimal(const char* s, int len, int type_precision, 
int type_scale,
                                   ParseResult* result) {
     // Special cases:
@@ -624,55 +624,112 @@ T StringParser::string_to_decimal(const char* s, int 
len, int type_precision, in
     }
 
     int precision = 0;
+    int max_digit = type_precision - type_scale;
     bool found_exponent = false;
     int8_t exponent = 0;
     T value = 0;
-    for (int i = 0; i < len; ++i) {
-        const char& c = s[i];
-        if (LIKELY('0' <= c && c <= '9')) {
-            found_value = true;
-            // Ignore digits once the type's precision limit is reached. This 
avoids
-            // overflowing the underlying storage while handling a string like
-            // 10000000000e-10 into a DECIMAL(1, 0). Adjustments for ignored 
digits and
-            // an exponent will be made later.
-            if (LIKELY(type_precision > precision)) {
-                value = (value * 10) + (c - '0'); // Benchmarks are faster 
with parenthesis...
+    if constexpr (TYPE_DECIMALV2 == P) {
+        // decimalv2 do not care type_scale and type_precision,just keep the 
origin logic
+        for (int i = 0; i < len; ++i) {
+            const char& c = s[i];
+            if (LIKELY('0' <= c && c <= '9')) {
+                found_value = true;
+                // Ignore digits once the type's precision limit is reached. 
This avoids
+                // overflowing the underlying storage while handling a string 
like
+                // 10000000000e-10 into a DECIMAL(1, 0). Adjustments for 
ignored digits and
+                // an exponent will be made later.
+                if (LIKELY(type_precision > precision)) {
+                    value = (value * 10) + (c - '0'); // Benchmarks are faster 
with parenthesis...
+                } else {
+                    *result = StringParser::PARSE_OVERFLOW;
+                    value = is_negative ? 
vectorized::min_decimal_value<vectorized::Decimal<T>>(
+                                                  type_precision)
+                                        : 
vectorized::max_decimal_value<vectorized::Decimal<T>>(
+                                                  type_precision);
+                    return value;
+                }
+                DCHECK(value >= 0); // For some reason //DCHECK_GE doesn't 
work with __int128.
+                ++precision;
+                scale += found_dot;
+            } else if (c == '.' && LIKELY(!found_dot)) {
+                found_dot = 1;
+            } else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
+                found_exponent = true;
+                exponent = string_to_int_internal<int8_t>(s + i + 1, len - i - 
1, result);
+                if (UNLIKELY(*result != StringParser::PARSE_SUCCESS)) {
+                    if (*result == StringParser::PARSE_OVERFLOW && exponent < 
0) {
+                        *result = StringParser::PARSE_UNDERFLOW;
+                    }
+                    return 0;
+                }
+                break;
             } else {
-                *result = StringParser::PARSE_OVERFLOW;
-                value = is_negative ? 
vectorized::min_decimal_value<vectorized::Decimal<T>>(
-                                              type_precision)
-                                    : 
vectorized::max_decimal_value<vectorized::Decimal<T>>(
-                                              type_precision);
-                return value;
-            }
-            DCHECK(value >= 0); // For some reason //DCHECK_GE doesn't work 
with __int128.
-            ++precision;
-            scale += found_dot;
-        } else if (c == '.' && LIKELY(!found_dot)) {
-            found_dot = 1;
-        } else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
-            found_exponent = true;
-            exponent = string_to_int_internal<int8_t>(s + i + 1, len - i - 1, 
result);
-            if (UNLIKELY(*result != StringParser::PARSE_SUCCESS)) {
-                if (*result == StringParser::PARSE_OVERFLOW && exponent < 0) {
-                    *result = StringParser::PARSE_UNDERFLOW;
+                if (value == 0) {
+                    *result = StringParser::PARSE_FAILURE;
+                    return 0;
                 }
-                return 0;
-            }
-            break;
-        } else {
-            if (value == 0) {
-                *result = StringParser::PARSE_FAILURE;
-                return 0;
+                *result = StringParser::PARSE_SUCCESS;
+                if constexpr (std::is_same_v<T, vectorized::Int128I>) {
+                    value *= get_scale_multiplier<__int128>(type_scale - 
scale);
+                } else {
+                    value *= get_scale_multiplier<T>(type_scale - scale);
+                }
+
+                return is_negative ? T(-value) : T(value);
             }
-            *result = StringParser::PARSE_SUCCESS;
-            if constexpr (std::is_same_v<T, vectorized::Int128I>) {
-                value *= get_scale_multiplier<__int128>(type_scale - scale);
+        }
+    } else {
+        // decimalv3
+        for (int i = 0; i < len; ++i) {
+            const char& c = s[i];
+            // keep a rounding precision to round the decimal value
+            if (LIKELY('0' <= c && c <= '9') && LIKELY(type_precision >= 
precision)) {
+                found_value = true;
+                // Ignore digits once the type's precision limit is reached. 
This avoids
+                // overflowing the underlying storage while handling a string 
like
+                // 10000000000e-10 into a DECIMAL(1, 0). Adjustments for 
ignored digits and
+                // an exponent will be made later.
+                ++precision;
+                scale += found_dot;
+                // decimalv3 should make sure the type_scale and type_precision
+                if (!found_dot && max_digit < (precision - scale)) {
+                    // parse_overflow should only happen when the digit part 
reached the max
+                    *result = StringParser::PARSE_OVERFLOW;
+                    value = is_negative ? 
vectorized::min_decimal_value<vectorized::Decimal<T>>(
+                                                  type_precision)
+                                        : 
vectorized::max_decimal_value<vectorized::Decimal<T>>(
+                                                  type_precision);
+                    return value;
+                }
+                // keep a rounding precision to round the decimal value
+                value = (value * 10) + (c - '0'); // Benchmarks are faster 
with parenthesis...
+                DCHECK(value >= 0); // For some reason //DCHECK_GE doesn't 
work with __int128.
+            } else if (c == '.' && LIKELY(!found_dot)) {
+                found_dot = 1;
+            } else if ((c == 'e' || c == 'E') && LIKELY(!found_exponent)) {
+                found_exponent = true;
+                exponent = string_to_int_internal<int8_t>(s + i + 1, len - i - 
1, result);
+                if (UNLIKELY(*result != StringParser::PARSE_SUCCESS)) {
+                    if (*result == StringParser::PARSE_OVERFLOW && exponent < 
0) {
+                        *result = StringParser::PARSE_UNDERFLOW;
+                    }
+                    return 0;
+                }
+                break;
             } else {
-                value *= get_scale_multiplier<T>(type_scale - scale);
-            }
+                if (value == 0) {
+                    *result = StringParser::PARSE_FAILURE;
+                    return 0;
+                }
+                *result = StringParser::PARSE_SUCCESS;
+                if constexpr (std::is_same_v<T, vectorized::Int128I>) {
+                    value *= get_scale_multiplier<__int128>(type_scale - 
scale);
+                } else {
+                    value *= get_scale_multiplier<T>(type_scale - scale);
+                }
 
-            return is_negative ? T(-value) : T(value);
+                return is_negative ? T(-value) : T(value);
+            }
         }
     }
 
diff --git a/be/src/vec/data_types/data_type_decimal.cpp 
b/be/src/vec/data_types/data_type_decimal.cpp
index cf31bd1e40..deb559f75b 100644
--- a/be/src/vec/data_types/data_type_decimal.cpp
+++ b/be/src/vec/data_types/data_type_decimal.cpp
@@ -88,9 +88,11 @@ template <typename T>
 Status DataTypeDecimal<T>::from_string(ReadBuffer& rb, IColumn* column) const {
     auto& column_data = static_cast<ColumnType&>(*column).get_data();
     T val = 0;
-    if (!read_decimal_text_impl<T>(val, rb, precision, scale)) {
-        return Status::InvalidArgument("parse decimal fail, string: '{}'",
-                                       std::string(rb.position(), 
rb.count()).c_str());
+    if (!read_decimal_text_impl<DataTypeDecimalSerDe<T>::get_primitive_type(), 
T>(
+                val, rb, precision, scale)) {
+        return Status::InvalidArgument("parse decimal fail, string: '{}', 
primitive type: '{}'",
+                                       std::string(rb.position(), 
rb.count()).c_str(),
+                                       
DataTypeDecimalSerDe<T>::get_primitive_type());
     }
     column_data.emplace_back(val);
     return Status::OK();
@@ -156,8 +158,8 @@ MutableColumnPtr DataTypeDecimal<T>::create_column() const {
 template <typename T>
 bool DataTypeDecimal<T>::parse_from_string(const std::string& str, T* res) 
const {
     StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
-    *res = StringParser::string_to_decimal<__int128>(str.c_str(), str.size(), 
precision, scale,
-                                                     &result);
+    *res = 
StringParser::string_to_decimal<DataTypeDecimalSerDe<T>::get_primitive_type(), 
__int128>(
+            str.c_str(), str.size(), precision, scale, &result);
     return result == StringParser::PARSE_SUCCESS;
 }
 
diff --git a/be/src/vec/data_types/serde/data_type_decimal_serde.h 
b/be/src/vec/data_types/serde/data_type_decimal_serde.h
index 2b64a00eca..4c64dc2ae3 100644
--- a/be/src/vec/data_types/serde/data_type_decimal_serde.h
+++ b/be/src/vec/data_types/serde/data_type_decimal_serde.h
@@ -47,6 +47,22 @@ class DataTypeDecimalSerDe : public DataTypeSerDe {
     static_assert(IsDecimalNumber<T>);
 
 public:
+    static constexpr PrimitiveType get_primitive_type() {
+        if constexpr (std::is_same_v<TypeId<T>, TypeId<Decimal32>>) {
+            return TYPE_DECIMAL32;
+        }
+        if constexpr (std::is_same_v<TypeId<T>, TypeId<Decimal64>>) {
+            return TYPE_DECIMAL64;
+        }
+        if constexpr (std::is_same_v<TypeId<T>, TypeId<Decimal128I>>) {
+            return TYPE_DECIMAL128I;
+        }
+        if constexpr (std::is_same_v<TypeId<T>, TypeId<Decimal128>>) {
+            return TYPE_DECIMALV2;
+        }
+        __builtin_unreachable();
+    }
+
     DataTypeDecimalSerDe(int scale_)
             : scale(scale_),
               scale_multiplier(decimal_scale_multiplier<typename 
T::NativeType>(scale)) {}
diff --git a/be/src/vec/functions/function_cast.h 
b/be/src/vec/functions/function_cast.h
index b8ad184c3e..4debe7c188 100644
--- a/be/src/vec/functions/function_cast.h
+++ b/be/src/vec/functions/function_cast.h
@@ -887,9 +887,24 @@ bool try_parse_impl(typename DataType::FieldType& x, 
ReadBuffer& rb,
         return try_read_int_text(x, rb);
     }
 
-    if constexpr (IsDataTypeDecimal<DataType>) {
+    if constexpr (IsDataTypeDecimalV2<DataType>) {
         UInt32 scale = additions;
-        return try_read_decimal_text(x, rb, DataType::max_precision(), scale);
+        return try_read_decimal_text<TYPE_DECIMALV2>(x, rb, 
DataType::max_precision(), scale);
+    }
+
+    if constexpr (std::is_same_v<DataTypeDecimal<Decimal32>, DataType>) {
+        UInt32 scale = additions;
+        return try_read_decimal_text<TYPE_DECIMAL32>(x, rb, 
DataType::max_precision(), scale);
+    }
+
+    if constexpr (std::is_same_v<DataTypeDecimal<Decimal64>, DataType>) {
+        UInt32 scale = additions;
+        return try_read_decimal_text<TYPE_DECIMAL64>(x, rb, 
DataType::max_precision(), scale);
+    }
+
+    if constexpr (IsDataTypeDecimal128I<DataType>) {
+        UInt32 scale = additions;
+        return try_read_decimal_text<TYPE_DECIMAL128I>(x, rb, 
DataType::max_precision(), scale);
     }
 }
 
diff --git a/be/src/vec/io/io_helper.h b/be/src/vec/io/io_helper.h
index 30b6278fa3..5f07d8ced1 100644
--- a/be/src/vec/io/io_helper.h
+++ b/be/src/vec/io/io_helper.h
@@ -346,13 +346,13 @@ bool read_datetime_v2_text_impl(T& x, ReadBuffer& buf, 
const cctz::time_zone& lo
     return ans;
 }
 
-template <typename T>
+template <PrimitiveType P, typename T>
 bool read_decimal_text_impl(T& x, ReadBuffer& buf, UInt32 precision, UInt32 
scale) {
     static_assert(IsDecimalNumber<T>);
     if constexpr (!std::is_same_v<Decimal128, T>) {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
 
-        x.value = StringParser::string_to_decimal<typename T::NativeType>(
+        x.value = StringParser::string_to_decimal<P, typename T::NativeType>(
                 (const char*)buf.position(), buf.count(), precision, scale, 
&result);
         // only to match the is_all_read() check to prevent return null
         buf.position() = buf.end();
@@ -360,9 +360,9 @@ bool read_decimal_text_impl(T& x, ReadBuffer& buf, UInt32 
precision, UInt32 scal
     } else {
         StringParser::ParseResult result = StringParser::PARSE_SUCCESS;
 
-        x.value = StringParser::string_to_decimal<__int128>(buf.position(), 
buf.count(),
-                                                            
DecimalV2Value::PRECISION,
-                                                            
DecimalV2Value::SCALE, &result);
+        x.value = StringParser::string_to_decimal<TYPE_DECIMALV2, __int128>(
+                buf.position(), buf.count(), DecimalV2Value::PRECISION, 
DecimalV2Value::SCALE,
+                &result);
 
         // only to match the is_all_read() check to prevent return null
         buf.position() = buf.end();
@@ -416,9 +416,9 @@ bool try_read_float_text(T& x, ReadBuffer& in) {
     return read_float_text_fast_impl<T>(x, in);
 }
 
-template <typename T>
+template <PrimitiveType P, typename T>
 bool try_read_decimal_text(T& x, ReadBuffer& in, UInt32 precision, UInt32 
scale) {
-    return read_decimal_text_impl<T>(x, in, precision, scale);
+    return read_decimal_text_impl<P, T>(x, in, precision, scale);
 }
 
 template <typename T>
diff --git a/be/test/vec/data_types/serde/data_type_serde_arrow_test.cpp 
b/be/test/vec/data_types/serde/data_type_serde_arrow_test.cpp
index 92fbcc97c0..3c5191c1cb 100644
--- a/be/test/vec/data_types/serde/data_type_serde_arrow_test.cpp
+++ b/be/test/vec/data_types/serde/data_type_serde_arrow_test.cpp
@@ -181,10 +181,10 @@ void serialize_and_deserialize_arrow_test() {
                     }
                     Int32 val;
                     StringParser::ParseResult result = 
StringParser::PARSE_SUCCESS;
-                    i % 2 == 0 ? val = 
StringParser::string_to_decimal<__int128>(
+                    i % 2 == 0 ? val = 
StringParser::string_to_decimal<TYPE_DECIMAL32, __int128>(
                                          "1234567.56", 11, 
type_desc.precision, type_desc.scale,
                                          &result)
-                               : val = 
StringParser::string_to_decimal<__int128>(
+                               : val = 
StringParser::string_to_decimal<TYPE_DECIMAL32, __int128>(
                                          "-1234567.56", 12, 
type_desc.precision, type_desc.scale,
                                          &result);
                     EXPECT_TRUE(result == StringParser::PARSE_SUCCESS);
@@ -217,7 +217,7 @@ void serialize_and_deserialize_arrow_test() {
                     StringParser::ParseResult result = 
StringParser::PARSE_SUCCESS;
                     std::string decimal_string =
                             i % 2 == 0 ? "-123456789012.123456" : 
"123456789012.123456";
-                    val = StringParser::string_to_decimal<__int128>(
+                    val = StringParser::string_to_decimal<TYPE_DECIMAL64, 
__int128>(
                             decimal_string.c_str(), decimal_string.size(), 
type_desc.precision,
                             type_desc.scale, &result);
                     EXPECT_TRUE(result == StringParser::PARSE_SUCCESS);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to