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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new aa0837f198 [bugfix](topn) fix topn runtime predicate getting value bug 
for decimal type (#16331)
aa0837f198 is described below

commit aa0837f198fe8546ba9d14577da74d29e1d710aa
Author: Kang <[email protected]>
AuthorDate: Thu Feb 2 09:13:32 2023 +0800

    [bugfix](topn) fix topn runtime predicate getting value bug for decimal 
type (#16331)
    
    * fix topn runtime predicate getting value bug for decimal type
    
    * fix cast_to_string bug for TYPE_DECIMALV2
---
 be/src/runtime/runtime_predicate.h | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/be/src/runtime/runtime_predicate.h 
b/be/src/runtime/runtime_predicate.h
index 1356127268..62ab5bcf48 100644
--- a/be/src/runtime/runtime_predicate.h
+++ b/be/src/runtime/runtime_predicate.h
@@ -147,30 +147,31 @@ private:
     }
 
     static std::string get_decimalv2_value(const Field& field) {
-        using ValueType = typename 
PrimitiveTypeTraits<TYPE_DECIMALV2>::CppType;
-        ValueType value;
+        // can NOT use PrimitiveTypeTraits<TYPE_DECIMALV2>::CppType since
+        //   it is DecimalV2Value and Decimal128 can not convert to it 
implicitly
+        using ValueType = Decimal128::NativeType;
         auto v = field.get<DecimalField<Decimal128>>();
-        value.from_olap_decimal(v.get_value(), v.get_scale());
-        int scale = v.get_scale();
-        return cast_to_string<TYPE_DECIMALV2, ValueType>(value, scale);
+        // use TYPE_DECIMAL128I instead of TYPE_DECIMALV2 since v.get_scale()
+        //   is always 9 for DECIMALV2
+        return cast_to_string<TYPE_DECIMAL128I, ValueType>(v.get_value(), 
v.get_scale());
     }
 
     static std::string get_decimal32_value(const Field& field) {
         using ValueType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL32>::CppType;
-        ValueType value = field.get<ValueType>();
-        return cast_to_string<TYPE_DECIMAL32, ValueType>(value, 0);
+        auto v = field.get<DecimalField<Decimal32>>();
+        return cast_to_string<TYPE_DECIMAL32, ValueType>(v.get_value(), 
v.get_scale());
     }
 
     static std::string get_decimal64_value(const Field& field) {
         using ValueType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL64>::CppType;
-        ValueType value = field.get<ValueType>();
-        return cast_to_string<TYPE_DECIMAL64, ValueType>(value, 0);
+        auto v = field.get<DecimalField<Decimal64>>();
+        return cast_to_string<TYPE_DECIMAL64, ValueType>(v.get_value(), 
v.get_scale());
     }
 
     static std::string get_decimal128_value(const Field& field) {
         using ValueType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL128I>::CppType;
-        ValueType value = field.get<ValueType>();
-        return cast_to_string<TYPE_DECIMAL128I, ValueType>(value, 0);
+        auto v = field.get<DecimalField<Decimal128I>>();
+        return cast_to_string<TYPE_DECIMAL128I, ValueType>(v.get_value(), 
v.get_scale());
     }
 };
 


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

Reply via email to