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