be/src/exprs/function/cast/cast_to_decimal.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <cmath> |
21 | | #include <type_traits> |
22 | | |
23 | | #include "common/status.h" |
24 | | #include "core/data_type/data_type_decimal.h" |
25 | | #include "core/data_type/data_type_number.h" |
26 | | #include "core/types.h" |
27 | | #include "exprs/function/cast/cast_to_basic_number_common.h" |
28 | | |
29 | | namespace doris { |
30 | | |
31 | | #define DECIMAL_CONVERT_OVERFLOW_ERROR(value, from_type_name, precision, scale) \ |
32 | 2.18k | Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, \ |
33 | 2.18k | fmt::format( \ |
34 | 2.18k | "Arithmetic overflow when converting value {} from type {} to decimal({}, {})", \ |
35 | 2.18k | value, from_type_name, precision, scale)) |
36 | | |
37 | | struct CastToDecimal { |
38 | | template <typename ToCppT> |
39 | | requires(IsDecimalNumber<ToCppT>) |
40 | | static inline bool from_string(const StringRef& from, ToCppT& to, UInt32 precision, |
41 | 112k | UInt32 scale, CastParameters& params) { |
42 | 112k | if constexpr (IsDecimalV2<ToCppT>) { |
43 | 14 | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
44 | 14 | to = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( |
45 | 14 | from.data, (int)from.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, |
46 | 14 | &result)); |
47 | 14 | return result == StringParser::PARSE_SUCCESS; |
48 | 14 | } |
49 | | |
50 | 30.2k | if constexpr (IsDecimal32<ToCppT>) { |
51 | 30.2k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
52 | 30.2k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL32>(from.data, (int)from.size, |
53 | 30.2k | precision, scale, &result); |
54 | 30.2k | return result == StringParser::PARSE_SUCCESS; |
55 | 30.2k | } |
56 | | |
57 | 27.4k | if constexpr (IsDecimal64<ToCppT>) { |
58 | 27.4k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
59 | 27.4k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL64>(from.data, (int)from.size, |
60 | 27.4k | precision, scale, &result); |
61 | 27.4k | return result == StringParser::PARSE_SUCCESS; |
62 | 27.4k | } |
63 | | |
64 | 27.4k | if constexpr (IsDecimal128V3<ToCppT>) { |
65 | 27.4k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
66 | 27.4k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL128I>(from.data, (int)from.size, |
67 | 27.4k | precision, scale, &result); |
68 | 27.4k | return result == StringParser::PARSE_SUCCESS; |
69 | 27.4k | } |
70 | | |
71 | 27.3k | if constexpr (IsDecimal256<ToCppT>) { |
72 | 27.3k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; |
73 | 27.3k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL256>(from.data, (int)from.size, |
74 | 27.3k | precision, scale, &result); |
75 | 27.3k | return result == StringParser::PARSE_SUCCESS; |
76 | 27.3k | } |
77 | 112k | } _ZN5doris13CastToDecimal11from_stringINS_7DecimalIiEEQ15IsDecimalNumberIT_EEEbRKNS_9StringRefERS4_jjRNS_14CastParametersE Line | Count | Source | 41 | 30.2k | UInt32 scale, CastParameters& params) { | 42 | | if constexpr (IsDecimalV2<ToCppT>) { | 43 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 44 | | to = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 45 | | from.data, (int)from.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 46 | | &result)); | 47 | | return result == StringParser::PARSE_SUCCESS; | 48 | | } | 49 | | | 50 | 30.2k | if constexpr (IsDecimal32<ToCppT>) { | 51 | 30.2k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 52 | 30.2k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL32>(from.data, (int)from.size, | 53 | 30.2k | precision, scale, &result); | 54 | 30.2k | return result == StringParser::PARSE_SUCCESS; | 55 | 30.2k | } | 56 | | | 57 | | if constexpr (IsDecimal64<ToCppT>) { | 58 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 59 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL64>(from.data, (int)from.size, | 60 | | precision, scale, &result); | 61 | | return result == StringParser::PARSE_SUCCESS; | 62 | | } | 63 | | | 64 | | if constexpr (IsDecimal128V3<ToCppT>) { | 65 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 66 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL128I>(from.data, (int)from.size, | 67 | | precision, scale, &result); | 68 | | return result == StringParser::PARSE_SUCCESS; | 69 | | } | 70 | | | 71 | | if constexpr (IsDecimal256<ToCppT>) { | 72 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 73 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL256>(from.data, (int)from.size, | 74 | | precision, scale, &result); | 75 | | return result == StringParser::PARSE_SUCCESS; | 76 | | } | 77 | 30.2k | } |
_ZN5doris13CastToDecimal11from_stringINS_7DecimalIlEEQ15IsDecimalNumberIT_EEEbRKNS_9StringRefERS4_jjRNS_14CastParametersE Line | Count | Source | 41 | 27.4k | UInt32 scale, CastParameters& params) { | 42 | | if constexpr (IsDecimalV2<ToCppT>) { | 43 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 44 | | to = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 45 | | from.data, (int)from.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 46 | | &result)); | 47 | | return result == StringParser::PARSE_SUCCESS; | 48 | | } | 49 | | | 50 | | if constexpr (IsDecimal32<ToCppT>) { | 51 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 52 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL32>(from.data, (int)from.size, | 53 | | precision, scale, &result); | 54 | | return result == StringParser::PARSE_SUCCESS; | 55 | | } | 56 | | | 57 | 27.4k | if constexpr (IsDecimal64<ToCppT>) { | 58 | 27.4k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 59 | 27.4k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL64>(from.data, (int)from.size, | 60 | 27.4k | precision, scale, &result); | 61 | 27.4k | return result == StringParser::PARSE_SUCCESS; | 62 | 27.4k | } | 63 | | | 64 | | if constexpr (IsDecimal128V3<ToCppT>) { | 65 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 66 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL128I>(from.data, (int)from.size, | 67 | | precision, scale, &result); | 68 | | return result == StringParser::PARSE_SUCCESS; | 69 | | } | 70 | | | 71 | | if constexpr (IsDecimal256<ToCppT>) { | 72 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 73 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL256>(from.data, (int)from.size, | 74 | | precision, scale, &result); | 75 | | return result == StringParser::PARSE_SUCCESS; | 76 | | } | 77 | 27.4k | } |
_ZN5doris13CastToDecimal11from_stringINS_12Decimal128V3EQ15IsDecimalNumberIT_EEEbRKNS_9StringRefERS3_jjRNS_14CastParametersE Line | Count | Source | 41 | 27.4k | UInt32 scale, CastParameters& params) { | 42 | | if constexpr (IsDecimalV2<ToCppT>) { | 43 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 44 | | to = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 45 | | from.data, (int)from.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 46 | | &result)); | 47 | | return result == StringParser::PARSE_SUCCESS; | 48 | | } | 49 | | | 50 | | if constexpr (IsDecimal32<ToCppT>) { | 51 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 52 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL32>(from.data, (int)from.size, | 53 | | precision, scale, &result); | 54 | | return result == StringParser::PARSE_SUCCESS; | 55 | | } | 56 | | | 57 | | if constexpr (IsDecimal64<ToCppT>) { | 58 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 59 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL64>(from.data, (int)from.size, | 60 | | precision, scale, &result); | 61 | | return result == StringParser::PARSE_SUCCESS; | 62 | | } | 63 | | | 64 | 27.4k | if constexpr (IsDecimal128V3<ToCppT>) { | 65 | 27.4k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 66 | 27.4k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL128I>(from.data, (int)from.size, | 67 | 27.4k | precision, scale, &result); | 68 | 27.4k | return result == StringParser::PARSE_SUCCESS; | 69 | 27.4k | } | 70 | | | 71 | | if constexpr (IsDecimal256<ToCppT>) { | 72 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 73 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL256>(from.data, (int)from.size, | 74 | | precision, scale, &result); | 75 | | return result == StringParser::PARSE_SUCCESS; | 76 | | } | 77 | 27.4k | } |
_ZN5doris13CastToDecimal11from_stringINS_14DecimalV2ValueEQ15IsDecimalNumberIT_EEEbRKNS_9StringRefERS3_jjRNS_14CastParametersE Line | Count | Source | 41 | 14 | UInt32 scale, CastParameters& params) { | 42 | 14 | if constexpr (IsDecimalV2<ToCppT>) { | 43 | 14 | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 44 | 14 | to = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 45 | 14 | from.data, (int)from.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 46 | 14 | &result)); | 47 | 14 | return result == StringParser::PARSE_SUCCESS; | 48 | 14 | } | 49 | | | 50 | | if constexpr (IsDecimal32<ToCppT>) { | 51 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 52 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL32>(from.data, (int)from.size, | 53 | | precision, scale, &result); | 54 | | return result == StringParser::PARSE_SUCCESS; | 55 | | } | 56 | | | 57 | | if constexpr (IsDecimal64<ToCppT>) { | 58 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 59 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL64>(from.data, (int)from.size, | 60 | | precision, scale, &result); | 61 | | return result == StringParser::PARSE_SUCCESS; | 62 | | } | 63 | | | 64 | | if constexpr (IsDecimal128V3<ToCppT>) { | 65 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 66 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL128I>(from.data, (int)from.size, | 67 | | precision, scale, &result); | 68 | | return result == StringParser::PARSE_SUCCESS; | 69 | | } | 70 | | | 71 | | if constexpr (IsDecimal256<ToCppT>) { | 72 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 73 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL256>(from.data, (int)from.size, | 74 | | precision, scale, &result); | 75 | | return result == StringParser::PARSE_SUCCESS; | 76 | | } | 77 | 14 | } |
_ZN5doris13CastToDecimal11from_stringINS_7DecimalIN4wide7integerILm256EiEEEEQ15IsDecimalNumberIT_EEEbRKNS_9StringRefERS7_jjRNS_14CastParametersE Line | Count | Source | 41 | 27.3k | UInt32 scale, CastParameters& params) { | 42 | | if constexpr (IsDecimalV2<ToCppT>) { | 43 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 44 | | to = DecimalV2Value(StringParser::string_to_decimal<TYPE_DECIMALV2>( | 45 | | from.data, (int)from.size, DecimalV2Value::PRECISION, DecimalV2Value::SCALE, | 46 | | &result)); | 47 | | return result == StringParser::PARSE_SUCCESS; | 48 | | } | 49 | | | 50 | | if constexpr (IsDecimal32<ToCppT>) { | 51 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 52 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL32>(from.data, (int)from.size, | 53 | | precision, scale, &result); | 54 | | return result == StringParser::PARSE_SUCCESS; | 55 | | } | 56 | | | 57 | | if constexpr (IsDecimal64<ToCppT>) { | 58 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 59 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL64>(from.data, (int)from.size, | 60 | | precision, scale, &result); | 61 | | return result == StringParser::PARSE_SUCCESS; | 62 | | } | 63 | | | 64 | | if constexpr (IsDecimal128V3<ToCppT>) { | 65 | | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 66 | | to.value = StringParser::string_to_decimal<TYPE_DECIMAL128I>(from.data, (int)from.size, | 67 | | precision, scale, &result); | 68 | | return result == StringParser::PARSE_SUCCESS; | 69 | | } | 70 | | | 71 | 27.3k | if constexpr (IsDecimal256<ToCppT>) { | 72 | 27.3k | StringParser::ParseResult result = StringParser::PARSE_SUCCESS; | 73 | 27.3k | to.value = StringParser::string_to_decimal<TYPE_DECIMAL256>(from.data, (int)from.size, | 74 | 27.3k | precision, scale, &result); | 75 | 27.3k | return result == StringParser::PARSE_SUCCESS; | 76 | 27.3k | } | 77 | 27.3k | } |
|
78 | | |
79 | | // cast int to decimal |
80 | | template <typename FromCppT, typename ToCppT, |
81 | | typename MaxNativeType = |
82 | | std::conditional_t<(sizeof(FromCppT) > sizeof(typename ToCppT::NativeType)), |
83 | | FromCppT, typename ToCppT::NativeType>> |
84 | | requires(IsDecimalNumber<ToCppT> && |
85 | | (IsCppTypeInt<FromCppT> || std::is_same_v<FromCppT, UInt8>)) |
86 | | static inline bool from_int(const FromCppT& from, ToCppT& to, UInt32 to_precision, |
87 | 7 | UInt32 to_scale, CastParameters& params) { |
88 | 7 | MaxNativeType scale_multiplier = |
89 | 7 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); |
90 | 7 | typename ToCppT::NativeType max_result = |
91 | 7 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); |
92 | 7 | typename ToCppT::NativeType min_result = -max_result; |
93 | | |
94 | 7 | UInt32 from_precision = NumberTraits::max_ascii_len<FromCppT>(); |
95 | 7 | constexpr UInt32 from_scale = 0; |
96 | 7 | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); |
97 | | |
98 | 7 | auto from_max_int_digit_count = from_precision - from_scale; |
99 | 7 | auto to_max_int_digit_count = to_precision - to_scale; |
100 | 7 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); |
101 | 7 | bool multiply_may_overflow = false; |
102 | 7 | if (to_scale > from_scale) { |
103 | 7 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; |
104 | 7 | } |
105 | 7 | return std::visit( |
106 | 7 | [&](auto multiply_may_overflow, auto narrow_integral) { |
107 | 7 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( |
108 | 7 | from, to, to_precision, to_scale, scale_multiplier, min_result, |
109 | 7 | max_result, params); |
110 | 7 | }, _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Line | Count | Source | 106 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 2 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 2 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 2 | max_result, params); | 110 | 2 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Line | Count | Source | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Line | Count | Source | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Line | Count | Source | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIiEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIiEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIiEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIiEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Line | Count | Source | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIiEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIiEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIiEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIiEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Line | Count | Source | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIlEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIlEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIlEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIlEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESC_IbLb1EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESC_IbLb0EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESC_IbLb1EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESC_IbLb0EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESC_IbLb1EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESC_IbLb0EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESC_IbLb1EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESC_IbLb0EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESC_IbLb1EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESC_IbLb0EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESC_IbLb1EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESC_IbLb0EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESG_IbLb1EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESG_IbLb0EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIhNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESG_IbLb1EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESG_IbLb0EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIaNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESG_IbLb1EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESG_IbLb0EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIsNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESG_IbLb1EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESG_IbLb0EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIiNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESG_IbLb1EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESG_IbLb0EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intIlNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESG_IbLb1EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESG_IbLb0EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal8from_intInNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESH_EEDaS8_S7_ |
111 | 7 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); |
112 | 7 | } _ZN5doris13CastToDecimal8from_intIhNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 87 | 2 | UInt32 to_scale, CastParameters& params) { | 88 | 2 | MaxNativeType scale_multiplier = | 89 | 2 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 90 | 2 | typename ToCppT::NativeType max_result = | 91 | 2 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 92 | 2 | typename ToCppT::NativeType min_result = -max_result; | 93 | | | 94 | 2 | UInt32 from_precision = NumberTraits::max_ascii_len<FromCppT>(); | 95 | 2 | constexpr UInt32 from_scale = 0; | 96 | 2 | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 97 | | | 98 | 2 | auto from_max_int_digit_count = from_precision - from_scale; | 99 | 2 | auto to_max_int_digit_count = to_precision - to_scale; | 100 | 2 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 101 | 2 | bool multiply_may_overflow = false; | 102 | 2 | if (to_scale > from_scale) { | 103 | 2 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 104 | 2 | } | 105 | 2 | return std::visit( | 106 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 2 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 2 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 2 | max_result, params); | 110 | 2 | }, | 111 | 2 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 112 | 2 | } |
_ZN5doris13CastToDecimal8from_intIaNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 87 | 1 | UInt32 to_scale, CastParameters& params) { | 88 | 1 | MaxNativeType scale_multiplier = | 89 | 1 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 90 | 1 | typename ToCppT::NativeType max_result = | 91 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 92 | 1 | typename ToCppT::NativeType min_result = -max_result; | 93 | | | 94 | 1 | UInt32 from_precision = NumberTraits::max_ascii_len<FromCppT>(); | 95 | 1 | constexpr UInt32 from_scale = 0; | 96 | 1 | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 97 | | | 98 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 99 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 100 | 1 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 101 | 1 | bool multiply_may_overflow = false; | 102 | 1 | if (to_scale > from_scale) { | 103 | 1 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 104 | 1 | } | 105 | 1 | return std::visit( | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, | 111 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 112 | 1 | } |
_ZN5doris13CastToDecimal8from_intIsNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 87 | 1 | UInt32 to_scale, CastParameters& params) { | 88 | 1 | MaxNativeType scale_multiplier = | 89 | 1 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 90 | 1 | typename ToCppT::NativeType max_result = | 91 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 92 | 1 | typename ToCppT::NativeType min_result = -max_result; | 93 | | | 94 | 1 | UInt32 from_precision = NumberTraits::max_ascii_len<FromCppT>(); | 95 | 1 | constexpr UInt32 from_scale = 0; | 96 | 1 | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 97 | | | 98 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 99 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 100 | 1 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 101 | 1 | bool multiply_may_overflow = false; | 102 | 1 | if (to_scale > from_scale) { | 103 | 1 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 104 | 1 | } | 105 | 1 | return std::visit( | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, | 111 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 112 | 1 | } |
_ZN5doris13CastToDecimal8from_intIiNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 87 | 1 | UInt32 to_scale, CastParameters& params) { | 88 | 1 | MaxNativeType scale_multiplier = | 89 | 1 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 90 | 1 | typename ToCppT::NativeType max_result = | 91 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 92 | 1 | typename ToCppT::NativeType min_result = -max_result; | 93 | | | 94 | 1 | UInt32 from_precision = NumberTraits::max_ascii_len<FromCppT>(); | 95 | 1 | constexpr UInt32 from_scale = 0; | 96 | 1 | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 97 | | | 98 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 99 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 100 | 1 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 101 | 1 | bool multiply_may_overflow = false; | 102 | 1 | if (to_scale > from_scale) { | 103 | 1 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 104 | 1 | } | 105 | 1 | return std::visit( | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, | 111 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 112 | 1 | } |
_ZN5doris13CastToDecimal8from_intIlNS_7DecimalIiEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 87 | 1 | UInt32 to_scale, CastParameters& params) { | 88 | 1 | MaxNativeType scale_multiplier = | 89 | 1 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 90 | 1 | typename ToCppT::NativeType max_result = | 91 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 92 | 1 | typename ToCppT::NativeType min_result = -max_result; | 93 | | | 94 | 1 | UInt32 from_precision = NumberTraits::max_ascii_len<FromCppT>(); | 95 | 1 | constexpr UInt32 from_scale = 0; | 96 | 1 | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 97 | | | 98 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 99 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 100 | 1 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 101 | 1 | bool multiply_may_overflow = false; | 102 | 1 | if (to_scale > from_scale) { | 103 | 1 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 104 | 1 | } | 105 | 1 | return std::visit( | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, | 111 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 112 | 1 | } |
_ZN5doris13CastToDecimal8from_intInNS_7DecimalIiEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 87 | 1 | UInt32 to_scale, CastParameters& params) { | 88 | 1 | MaxNativeType scale_multiplier = | 89 | 1 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 90 | 1 | typename ToCppT::NativeType max_result = | 91 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 92 | 1 | typename ToCppT::NativeType min_result = -max_result; | 93 | | | 94 | 1 | UInt32 from_precision = NumberTraits::max_ascii_len<FromCppT>(); | 95 | 1 | constexpr UInt32 from_scale = 0; | 96 | 1 | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 97 | | | 98 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 99 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 100 | 1 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 101 | 1 | bool multiply_may_overflow = false; | 102 | 1 | if (to_scale > from_scale) { | 103 | 1 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 104 | 1 | } | 105 | 1 | return std::visit( | 106 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 107 | 1 | return _from_int<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 108 | 1 | from, to, to_precision, to_scale, scale_multiplier, min_result, | 109 | 1 | max_result, params); | 110 | 1 | }, | 111 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 112 | 1 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIhNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIaNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIsNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIiNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIlNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intInNS_7DecimalIlEEnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIhNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIaNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIsNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIiNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIlNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intInNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIhNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIaNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIsNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIiNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intIlNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal8from_intInNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRNS_14CastParametersE |
113 | | |
114 | | // cast bool to decimal |
115 | | template <typename FromCppT, typename ToCppT, |
116 | | typename MaxNativeType = |
117 | | std::conditional_t<(sizeof(FromCppT) > sizeof(typename ToCppT::NativeType)), |
118 | | FromCppT, typename ToCppT::NativeType>> |
119 | | requires(IsDecimalNumber<ToCppT> && std::is_same_v<FromCppT, UInt8>) |
120 | | static inline bool from_bool(const FromCppT& from, ToCppT& to, UInt32 to_precision, |
121 | 2 | UInt32 to_scale, CastParameters& params) { |
122 | 2 | return from_int<FromCppT, ToCppT, MaxNativeType>(from, to, to_precision, to_scale, params); |
123 | 2 | } _ZN5doris13CastToDecimal9from_boolIhNS_7DecimalIiEEiQaa15IsDecimalNumberIT0_Esr3stdE9is_same_vIT_hEEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 121 | 2 | UInt32 to_scale, CastParameters& params) { | 122 | 2 | return from_int<FromCppT, ToCppT, MaxNativeType>(from, to, to_precision, to_scale, params); | 123 | 2 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9from_boolIhNS_7DecimalIlEElQaa15IsDecimalNumberIT0_Esr3stdE9is_same_vIT_hEEEbRKS5_RS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9from_boolIhNS_12Decimal128V3EnQaa15IsDecimalNumberIT0_Esr3stdE9is_same_vIT_hEEEbRKS4_RS3_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9from_boolIhNS_7DecimalIN4wide7integerILm256EiEEEES5_Qaa15IsDecimalNumberIT0_Esr3stdE9is_same_vIT_hEEEbRKS8_RS7_jjRNS_14CastParametersE |
124 | | |
125 | | template <typename FromCppT, typename ToCppT> |
126 | | requires(IsDecimalNumber<ToCppT> && IsCppTypeFloat<FromCppT>) |
127 | | static inline bool from_float(const FromCppT& from, ToCppT& to, UInt32 to_precision, |
128 | 204 | UInt32 to_scale, CastParameters& params) { |
129 | 204 | typename ToCppT::NativeType scale_multiplier = |
130 | 204 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); |
131 | 204 | typename ToCppT::NativeType max_result = |
132 | 204 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); |
133 | 204 | typename ToCppT::NativeType min_result = -max_result; |
134 | | |
135 | 204 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, |
136 | 204 | max_result, params); |
137 | 204 | } _ZN5doris13CastToDecimal10from_floatIdNS_7DecimalIiEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 128 | 33 | UInt32 to_scale, CastParameters& params) { | 129 | 33 | typename ToCppT::NativeType scale_multiplier = | 130 | 33 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 33 | typename ToCppT::NativeType max_result = | 132 | 33 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 33 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 33 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 33 | max_result, params); | 137 | 33 | } |
_ZN5doris13CastToDecimal10from_floatIfNS_7DecimalIiEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 128 | 5 | UInt32 to_scale, CastParameters& params) { | 129 | 5 | typename ToCppT::NativeType scale_multiplier = | 130 | 5 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 5 | typename ToCppT::NativeType max_result = | 132 | 5 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 5 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 5 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 5 | max_result, params); | 137 | 5 | } |
_ZN5doris13CastToDecimal10from_floatIdNS_7DecimalIlEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 128 | 40 | UInt32 to_scale, CastParameters& params) { | 129 | 40 | typename ToCppT::NativeType scale_multiplier = | 130 | 40 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 40 | typename ToCppT::NativeType max_result = | 132 | 40 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 40 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 40 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 40 | max_result, params); | 137 | 40 | } |
_ZN5doris13CastToDecimal10from_floatIfNS_7DecimalIlEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRNS_14CastParametersE Line | Count | Source | 128 | 4 | UInt32 to_scale, CastParameters& params) { | 129 | 4 | typename ToCppT::NativeType scale_multiplier = | 130 | 4 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 4 | typename ToCppT::NativeType max_result = | 132 | 4 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 4 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 4 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 4 | max_result, params); | 137 | 4 | } |
_ZN5doris13CastToDecimal10from_floatIdNS_12Decimal128V3EQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRNS_14CastParametersE Line | Count | Source | 128 | 52 | UInt32 to_scale, CastParameters& params) { | 129 | 52 | typename ToCppT::NativeType scale_multiplier = | 130 | 52 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 52 | typename ToCppT::NativeType max_result = | 132 | 52 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 52 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 52 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 52 | max_result, params); | 137 | 52 | } |
_ZN5doris13CastToDecimal10from_floatIfNS_12Decimal128V3EQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRNS_14CastParametersE Line | Count | Source | 128 | 4 | UInt32 to_scale, CastParameters& params) { | 129 | 4 | typename ToCppT::NativeType scale_multiplier = | 130 | 4 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 4 | typename ToCppT::NativeType max_result = | 132 | 4 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 4 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 4 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 4 | max_result, params); | 137 | 4 | } |
_ZN5doris13CastToDecimal10from_floatIdNS_7DecimalIN4wide7integerILm256EiEEEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS8_RS7_jjRNS_14CastParametersE Line | Count | Source | 128 | 58 | UInt32 to_scale, CastParameters& params) { | 129 | 58 | typename ToCppT::NativeType scale_multiplier = | 130 | 58 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 58 | typename ToCppT::NativeType max_result = | 132 | 58 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 58 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 58 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 58 | max_result, params); | 137 | 58 | } |
_ZN5doris13CastToDecimal10from_floatIfNS_7DecimalIN4wide7integerILm256EiEEEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS8_RS7_jjRNS_14CastParametersE Line | Count | Source | 128 | 4 | UInt32 to_scale, CastParameters& params) { | 129 | 4 | typename ToCppT::NativeType scale_multiplier = | 130 | 4 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 4 | typename ToCppT::NativeType max_result = | 132 | 4 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 4 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 4 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 4 | max_result, params); | 137 | 4 | } |
_ZN5doris13CastToDecimal10from_floatIdNS_14DecimalV2ValueEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRNS_14CastParametersE Line | Count | Source | 128 | 4 | UInt32 to_scale, CastParameters& params) { | 129 | 4 | typename ToCppT::NativeType scale_multiplier = | 130 | 4 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_scale); | 131 | 4 | typename ToCppT::NativeType max_result = | 132 | 4 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 133 | 4 | typename ToCppT::NativeType min_result = -max_result; | 134 | | | 135 | 4 | return _from_float(from, to, to_precision, to_scale, scale_multiplier, min_result, | 136 | 4 | max_result, params); | 137 | 4 | } |
|
138 | | |
139 | | template <typename FromCppT, typename ToCppT, |
140 | | typename MaxFieldType = std::conditional_t< |
141 | | (sizeof(FromCppT) == sizeof(ToCppT)) && |
142 | | (std::is_same_v<ToCppT, Decimal128V3> || |
143 | | std::is_same_v<FromCppT, Decimal128V3>), |
144 | | Decimal128V3, |
145 | | std::conditional_t<(sizeof(FromCppT) > sizeof(ToCppT)), FromCppT, ToCppT>>> |
146 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
147 | | static inline bool from_decimal(const FromCppT& from, const UInt32 from_precision, |
148 | | const UInt32 from_scale, ToCppT& to, UInt32 to_precision, |
149 | 5 | UInt32 to_scale, CastParameters& params) { |
150 | 5 | return _from_decimalv3<FromCppT, ToCppT, MaxFieldType>(from, from_precision, from_scale, to, |
151 | 5 | to_precision, to_scale, params); |
152 | 5 | } _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIiEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersE Line | Count | Source | 149 | 1 | UInt32 to_scale, CastParameters& params) { | 150 | 1 | return _from_decimalv3<FromCppT, ToCppT, MaxFieldType>(from, from_precision, from_scale, to, | 151 | 1 | to_precision, to_scale, params); | 152 | 1 | } |
_ZN5doris13CastToDecimal12from_decimalINS_7DecimalIlEENS2_IiEES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Line | Count | Source | 149 | 1 | UInt32 to_scale, CastParameters& params) { | 150 | 1 | return _from_decimalv3<FromCppT, ToCppT, MaxFieldType>(from, from_precision, from_scale, to, | 151 | 1 | to_precision, to_scale, params); | 152 | 1 | } |
_ZN5doris13CastToDecimal12from_decimalINS_12Decimal128V3ENS_7DecimalIiEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Line | Count | Source | 149 | 1 | UInt32 to_scale, CastParameters& params) { | 150 | 1 | return _from_decimalv3<FromCppT, ToCppT, MaxFieldType>(from, from_precision, from_scale, to, | 151 | 1 | to_precision, to_scale, params); | 152 | 1 | } |
_ZN5doris13CastToDecimal12from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Line | Count | Source | 149 | 1 | UInt32 to_scale, CastParameters& params) { | 150 | 1 | return _from_decimalv3<FromCppT, ToCppT, MaxFieldType>(from, from_precision, from_scale, to, | 151 | 1 | to_precision, to_scale, params); | 152 | 1 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIiEENS2_IlEES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIlEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_12Decimal128V3ENS_7DecimalIlEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIiEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIlEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE _ZN5doris13CastToDecimal12from_decimalINS_12Decimal128V3ES2_S2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRNS_14CastParametersE Line | Count | Source | 149 | 1 | UInt32 to_scale, CastParameters& params) { | 150 | 1 | return _from_decimalv3<FromCppT, ToCppT, MaxFieldType>(from, from_precision, from_scale, to, | 151 | 1 | to_precision, to_scale, params); | 152 | 1 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal12from_decimalINS_7DecimalIN4wide7integerILm256EiEEEES6_S6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRNS_14CastParametersE |
153 | | |
154 | | template <typename FromCppT, typename ToCppT, |
155 | | typename MaxFieldType = std::conditional_t< |
156 | | (sizeof(FromCppT) == sizeof(ToCppT)) && |
157 | | (std::is_same_v<ToCppT, Decimal128V3> || |
158 | | std::is_same_v<FromCppT, Decimal128V3>), |
159 | | Decimal128V3, |
160 | | std::conditional_t<(sizeof(FromCppT) > sizeof(ToCppT)), FromCppT, ToCppT>>> |
161 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
162 | | static inline bool _from_decimalv3(const FromCppT& from, const UInt32 from_precision, |
163 | | const UInt32 from_scale, ToCppT& to, UInt32 to_precision, |
164 | 5 | UInt32 to_scale, CastParameters& params) { |
165 | 5 | using MaxNativeType = typename MaxFieldType::NativeType; |
166 | | |
167 | 5 | auto from_max_int_digit_count = from_precision - from_scale; |
168 | 5 | auto to_max_int_digit_count = to_precision - to_scale; |
169 | 5 | bool narrow_integral = |
170 | 5 | (to_max_int_digit_count < from_max_int_digit_count) || |
171 | 5 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); |
172 | | |
173 | 5 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); |
174 | 5 | bool multiply_may_overflow = false; |
175 | 5 | if (to_scale > from_scale) { |
176 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; |
177 | 0 | } |
178 | | |
179 | 5 | typename ToCppT::NativeType max_result = |
180 | 5 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); |
181 | 5 | typename ToCppT::NativeType min_result = -max_result; |
182 | | |
183 | 5 | MaxNativeType multiplier {}; |
184 | 5 | if (from_scale < to_scale) { |
185 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - |
186 | 0 | from_scale); |
187 | 5 | } else if (from_scale > to_scale) { |
188 | 3 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - |
189 | 3 | to_scale); |
190 | 3 | } |
191 | | |
192 | 5 | return std::visit( |
193 | 5 | [&](auto multiply_may_overflow, auto narrow_integral) { |
194 | 5 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( |
195 | 5 | from, from_precision, from_scale, to, to_precision, to_scale, |
196 | 5 | min_result, max_result, multiplier, params); |
197 | 5 | }, _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Line | Count | Source | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IiEES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESF_EEDaS6_S5_ _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IiEES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESE_IbLb1EEEEDaS6_S5_ Line | Count | Source | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IiEES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESE_IbLb0EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IiEES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIiEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESF_EEDaS6_S5_ _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIiEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESE_IbLb1EEEEDaS6_S5_ Line | Count | Source | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIiEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESE_IbLb0EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIiEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESI_EEDaS9_S8_ _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESH_IbLb1EEEEDaS9_S8_ Line | Count | Source | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESH_IbLb0EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IlEES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IlEES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESE_IbLb1EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IlEES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESE_IbLb0EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IlEES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb0EESD_IbLb1EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESD_IbLb0EEEEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersEENKUlS5_S4_E_clISt17integral_constantIbLb1EESE_EEDaS5_S4_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIlEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIlEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESE_IbLb1EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIlEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESE_IbLb0EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIlEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESH_IbLb1EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESH_IbLb0EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESE_IbLb1EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESE_IbLb0EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESF_EEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb0EESE_IbLb1EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESE_IbLb0EEEEDaS6_S5_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersEENKUlS6_S5_E_clISt17integral_constantIbLb1EESF_EEDaS6_S5_ _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ES2_S2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESD_EEDaS4_S3_ Line | Count | Source | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, |
Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ES2_S2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb0EESC_IbLb1EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ES2_S2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESC_IbLb0EEEEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ES2_S2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRNS_14CastParametersEENKUlS4_S3_E_clISt17integral_constantIbLb1EESD_EEDaS4_S3_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESH_IbLb1EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESH_IbLb0EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESH_IbLb1EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESH_IbLb0EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESH_IbLb1EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESH_IbLb0EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb0EESH_IbLb1EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESH_IbLb0EEEEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersEENKUlS9_S8_E_clISt17integral_constantIbLb1EESI_EEDaS9_S8_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEES6_S6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESH_EEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEES6_S6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb0EESG_IbLb1EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEES6_S6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESG_IbLb0EEEEDaS8_S7_ Unexecuted instantiation: _ZZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEES6_S6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRNS_14CastParametersEENKUlS8_S7_E_clISt17integral_constantIbLb1EESH_EEDaS8_S7_ |
198 | 5 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); |
199 | 5 | } _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersE Line | Count | Source | 164 | 1 | UInt32 to_scale, CastParameters& params) { | 165 | 1 | using MaxNativeType = typename MaxFieldType::NativeType; | 166 | | | 167 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 168 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 169 | 1 | bool narrow_integral = | 170 | 1 | (to_max_int_digit_count < from_max_int_digit_count) || | 171 | 1 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 172 | | | 173 | 1 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 174 | 1 | bool multiply_may_overflow = false; | 175 | 1 | if (to_scale > from_scale) { | 176 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 177 | 0 | } | 178 | | | 179 | 1 | typename ToCppT::NativeType max_result = | 180 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 181 | 1 | typename ToCppT::NativeType min_result = -max_result; | 182 | | | 183 | 1 | MaxNativeType multiplier {}; | 184 | 1 | if (from_scale < to_scale) { | 185 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 186 | 0 | from_scale); | 187 | 1 | } else if (from_scale > to_scale) { | 188 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 189 | 0 | to_scale); | 190 | 0 | } | 191 | | | 192 | 1 | return std::visit( | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, | 198 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 199 | 1 | } |
_ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IiEES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Line | Count | Source | 164 | 1 | UInt32 to_scale, CastParameters& params) { | 165 | 1 | using MaxNativeType = typename MaxFieldType::NativeType; | 166 | | | 167 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 168 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 169 | 1 | bool narrow_integral = | 170 | 1 | (to_max_int_digit_count < from_max_int_digit_count) || | 171 | 1 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 172 | | | 173 | 1 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 174 | 1 | bool multiply_may_overflow = false; | 175 | 1 | if (to_scale > from_scale) { | 176 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 177 | 0 | } | 178 | | | 179 | 1 | typename ToCppT::NativeType max_result = | 180 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 181 | 1 | typename ToCppT::NativeType min_result = -max_result; | 182 | | | 183 | 1 | MaxNativeType multiplier {}; | 184 | 1 | if (from_scale < to_scale) { | 185 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 186 | 0 | from_scale); | 187 | 1 | } else if (from_scale > to_scale) { | 188 | 1 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 189 | 1 | to_scale); | 190 | 1 | } | 191 | | | 192 | 1 | return std::visit( | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, | 198 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 199 | 1 | } |
_ZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIiEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Line | Count | Source | 164 | 1 | UInt32 to_scale, CastParameters& params) { | 165 | 1 | using MaxNativeType = typename MaxFieldType::NativeType; | 166 | | | 167 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 168 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 169 | 1 | bool narrow_integral = | 170 | 1 | (to_max_int_digit_count < from_max_int_digit_count) || | 171 | 1 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 172 | | | 173 | 1 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 174 | 1 | bool multiply_may_overflow = false; | 175 | 1 | if (to_scale > from_scale) { | 176 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 177 | 0 | } | 178 | | | 179 | 1 | typename ToCppT::NativeType max_result = | 180 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 181 | 1 | typename ToCppT::NativeType min_result = -max_result; | 182 | | | 183 | 1 | MaxNativeType multiplier {}; | 184 | 1 | if (from_scale < to_scale) { | 185 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 186 | 0 | from_scale); | 187 | 1 | } else if (from_scale > to_scale) { | 188 | 1 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 189 | 1 | to_scale); | 190 | 1 | } | 191 | | | 192 | 1 | return std::visit( | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, | 198 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 199 | 1 | } |
_ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Line | Count | Source | 164 | 1 | UInt32 to_scale, CastParameters& params) { | 165 | 1 | using MaxNativeType = typename MaxFieldType::NativeType; | 166 | | | 167 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 168 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 169 | 1 | bool narrow_integral = | 170 | 1 | (to_max_int_digit_count < from_max_int_digit_count) || | 171 | 1 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 172 | | | 173 | 1 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 174 | 1 | bool multiply_may_overflow = false; | 175 | 1 | if (to_scale > from_scale) { | 176 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 177 | 0 | } | 178 | | | 179 | 1 | typename ToCppT::NativeType max_result = | 180 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 181 | 1 | typename ToCppT::NativeType min_result = -max_result; | 182 | | | 183 | 1 | MaxNativeType multiplier {}; | 184 | 1 | if (from_scale < to_scale) { | 185 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 186 | 0 | from_scale); | 187 | 1 | } else if (from_scale > to_scale) { | 188 | 1 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 189 | 1 | to_scale); | 190 | 1 | } | 191 | | | 192 | 1 | return std::visit( | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, | 198 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 199 | 1 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IlEES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEES3_S3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIlEES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS_12Decimal128V3ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRNS_14CastParametersE _ZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ES2_S2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRNS_14CastParametersE Line | Count | Source | 164 | 1 | UInt32 to_scale, CastParameters& params) { | 165 | 1 | using MaxNativeType = typename MaxFieldType::NativeType; | 166 | | | 167 | 1 | auto from_max_int_digit_count = from_precision - from_scale; | 168 | 1 | auto to_max_int_digit_count = to_precision - to_scale; | 169 | 1 | bool narrow_integral = | 170 | 1 | (to_max_int_digit_count < from_max_int_digit_count) || | 171 | 1 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 172 | | | 173 | 1 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); | 174 | 1 | bool multiply_may_overflow = false; | 175 | 1 | if (to_scale > from_scale) { | 176 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 177 | 0 | } | 178 | | | 179 | 1 | typename ToCppT::NativeType max_result = | 180 | 1 | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); | 181 | 1 | typename ToCppT::NativeType min_result = -max_result; | 182 | | | 183 | 1 | MaxNativeType multiplier {}; | 184 | 1 | if (from_scale < to_scale) { | 185 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 186 | 0 | from_scale); | 187 | 1 | } else if (from_scale > to_scale) { | 188 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 189 | 0 | to_scale); | 190 | 0 | } | 191 | | | 192 | 1 | return std::visit( | 193 | 1 | [&](auto multiply_may_overflow, auto narrow_integral) { | 194 | 1 | return _from_decimal<FromCppT, ToCppT, multiply_may_overflow, narrow_integral>( | 195 | 1 | from, from_precision, from_scale, to, to_precision, to_scale, | 196 | 1 | min_result, max_result, multiplier, params); | 197 | 1 | }, | 198 | 1 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); | 199 | 1 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal15_from_decimalv3INS_7DecimalIN4wide7integerILm256EiEEEES6_S6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRNS_14CastParametersE |
200 | | |
201 | | template <typename FromCppT, typename ToCppT, bool multiply_may_overflow, bool narrow_integral, |
202 | | typename MaxFieldType = std::conditional_t< |
203 | | (sizeof(FromCppT) == sizeof(ToCppT)) && |
204 | | (std::is_same_v<ToCppT, Decimal128V3> || |
205 | | std::is_same_v<FromCppT, Decimal128V3>), |
206 | | Decimal128V3, |
207 | | std::conditional_t<(sizeof(FromCppT) > sizeof(ToCppT)), FromCppT, ToCppT>>> |
208 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
209 | | static inline bool _from_decimal(const FromCppT& from, const UInt32 from_precision, |
210 | | const UInt32 from_scale, ToCppT& to, UInt32 to_precision, |
211 | | UInt32 to_scale, const ToCppT::NativeType& min_result, |
212 | | const ToCppT::NativeType& max_result, |
213 | | const typename MaxFieldType::NativeType& scale_multiplier, |
214 | 14.8k | CastParameters& params) { |
215 | 14.8k | using MaxNativeType = typename MaxFieldType::NativeType; |
216 | | |
217 | 14.8k | if (from_scale < to_scale) { |
218 | 4.60k | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, |
219 | 4.60k | narrow_integral>( |
220 | 4.60k | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, |
221 | 4.60k | min_result, max_result, params); |
222 | 10.2k | } else if (from_scale == to_scale) { |
223 | 1.86k | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( |
224 | 1.86k | from, from_precision, from_scale, to, to_precision, to_scale, min_result, |
225 | 1.86k | max_result, params); |
226 | 8.39k | } else { |
227 | 8.39k | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, |
228 | 8.39k | narrow_integral>( |
229 | 8.39k | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, |
230 | 8.39k | min_result, max_result, params); |
231 | 8.39k | } |
232 | 0 | return true; |
233 | 14.8k | } _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEES3_Lb0ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 134 | CastParameters& params) { | 215 | 134 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 134 | if (from_scale < to_scale) { | 218 | 14 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 14 | narrow_integral>( | 220 | 14 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 14 | min_result, max_result, params); | 222 | 120 | } else if (from_scale == to_scale) { | 223 | 8 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 8 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 8 | max_result, params); | 226 | 112 | } else { | 227 | 112 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 112 | narrow_integral>( | 229 | 112 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 112 | min_result, max_result, params); | 231 | 112 | } | 232 | 0 | return true; | 233 | 134 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEES3_Lb0ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 124 | CastParameters& params) { | 215 | 124 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 124 | if (from_scale < to_scale) { | 218 | 7 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 7 | narrow_integral>( | 220 | 7 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 7 | min_result, max_result, params); | 222 | 117 | } else if (from_scale == to_scale) { | 223 | 19 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 19 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 19 | max_result, params); | 226 | 98 | } else { | 227 | 98 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 98 | narrow_integral>( | 229 | 98 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 98 | min_result, max_result, params); | 231 | 98 | } | 232 | 0 | return true; | 233 | 124 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEES3_Lb1ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEES3_Lb1ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 84 | CastParameters& params) { | 215 | 84 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 84 | if (from_scale < to_scale) { | 218 | 84 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 84 | narrow_integral>( | 220 | 84 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 84 | min_result, max_result, params); | 222 | 84 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 84 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IiEELb0ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 160 | CastParameters& params) { | 215 | 160 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 160 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 160 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 160 | } else { | 227 | 160 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 160 | narrow_integral>( | 229 | 160 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 160 | min_result, max_result, params); | 231 | 160 | } | 232 | 0 | return true; | 233 | 160 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IiEELb0ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 459 | CastParameters& params) { | 215 | 459 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 459 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 459 | } else if (from_scale == to_scale) { | 223 | 136 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 136 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 136 | max_result, params); | 226 | 323 | } else { | 227 | 323 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 323 | narrow_integral>( | 229 | 323 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 323 | min_result, max_result, params); | 231 | 323 | } | 232 | 0 | return true; | 233 | 459 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IiEELb1ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IiEELb1ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 126 | CastParameters& params) { | 215 | 126 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 126 | if (from_scale < to_scale) { | 218 | 126 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 126 | narrow_integral>( | 220 | 126 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 126 | min_result, max_result, params); | 222 | 126 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 126 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIiEELb0ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 160 | CastParameters& params) { | 215 | 160 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 160 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 160 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 160 | } else { | 227 | 160 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 160 | narrow_integral>( | 229 | 160 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 160 | min_result, max_result, params); | 231 | 160 | } | 232 | 0 | return true; | 233 | 160 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIiEELb0ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 479 | CastParameters& params) { | 215 | 479 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 479 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 479 | } else if (from_scale == to_scale) { | 223 | 122 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 122 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 122 | max_result, params); | 226 | 357 | } else { | 227 | 357 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 357 | narrow_integral>( | 229 | 357 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 357 | min_result, max_result, params); | 231 | 357 | } | 232 | 0 | return true; | 233 | 479 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIiEELb1ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIiEELb1ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 126 | CastParameters& params) { | 215 | 126 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 126 | if (from_scale < to_scale) { | 218 | 126 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 126 | narrow_integral>( | 220 | 126 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 126 | min_result, max_result, params); | 222 | 126 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 126 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 160 | CastParameters& params) { | 215 | 160 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 160 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 160 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 160 | } else { | 227 | 160 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 160 | narrow_integral>( | 229 | 160 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 160 | min_result, max_result, params); | 231 | 160 | } | 232 | 0 | return true; | 233 | 160 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 479 | CastParameters& params) { | 215 | 479 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 479 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 479 | } else if (from_scale == to_scale) { | 223 | 122 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 122 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 122 | max_result, params); | 226 | 357 | } else { | 227 | 357 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 357 | narrow_integral>( | 229 | 357 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 357 | min_result, max_result, params); | 231 | 357 | } | 232 | 0 | return true; | 233 | 479 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 126 | CastParameters& params) { | 215 | 126 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 126 | if (from_scale < to_scale) { | 218 | 126 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 126 | narrow_integral>( | 220 | 126 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 126 | min_result, max_result, params); | 222 | 126 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 126 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IlEELb0ELb0ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 378 | CastParameters& params) { | 215 | 378 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 378 | if (from_scale < to_scale) { | 218 | 112 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 112 | narrow_integral>( | 220 | 112 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 112 | min_result, max_result, params); | 222 | 266 | } else if (from_scale == to_scale) { | 223 | 82 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 82 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 82 | max_result, params); | 226 | 184 | } else { | 227 | 184 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 184 | narrow_integral>( | 229 | 184 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 184 | min_result, max_result, params); | 231 | 184 | } | 232 | 0 | return true; | 233 | 378 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IlEELb0ELb1ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 58 | CastParameters& params) { | 215 | 58 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 58 | if (from_scale < to_scale) { | 218 | 58 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 58 | narrow_integral>( | 220 | 58 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 58 | min_result, max_result, params); | 222 | 58 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 58 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IlEELb1ELb0ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IlEELb1ELb1ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 72 | CastParameters& params) { | 215 | 72 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 72 | if (from_scale < to_scale) { | 218 | 72 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 72 | narrow_integral>( | 220 | 72 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 72 | min_result, max_result, params); | 222 | 72 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 72 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEES3_Lb0ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 428 | CastParameters& params) { | 215 | 428 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 428 | if (from_scale < to_scale) { | 218 | 46 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 46 | narrow_integral>( | 220 | 46 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 46 | min_result, max_result, params); | 222 | 382 | } else if (from_scale == to_scale) { | 223 | 30 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 30 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 30 | max_result, params); | 226 | 352 | } else { | 227 | 352 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 352 | narrow_integral>( | 229 | 352 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 352 | min_result, max_result, params); | 231 | 352 | } | 232 | 0 | return true; | 233 | 428 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEES3_Lb0ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 182 | CastParameters& params) { | 215 | 182 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 182 | if (from_scale < to_scale) { | 218 | 44 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 44 | narrow_integral>( | 220 | 44 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 44 | min_result, max_result, params); | 222 | 138 | } else if (from_scale == to_scale) { | 223 | 42 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 42 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 42 | max_result, params); | 226 | 96 | } else { | 227 | 96 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 96 | narrow_integral>( | 229 | 96 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 96 | min_result, max_result, params); | 231 | 96 | } | 232 | 0 | return true; | 233 | 182 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEES3_Lb1ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEES3_Lb1ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 210 | CastParameters& params) { | 215 | 210 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 210 | if (from_scale < to_scale) { | 218 | 210 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 210 | narrow_integral>( | 220 | 210 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 210 | min_result, max_result, params); | 222 | 210 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 210 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIlEELb0ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 288 | CastParameters& params) { | 215 | 288 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 288 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 288 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 288 | } else { | 227 | 288 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 288 | narrow_integral>( | 229 | 288 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 288 | min_result, max_result, params); | 231 | 288 | } | 232 | 0 | return true; | 233 | 288 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIlEELb0ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 532 | CastParameters& params) { | 215 | 532 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 532 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 532 | } else if (from_scale == to_scale) { | 223 | 182 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 182 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 182 | max_result, params); | 226 | 350 | } else { | 227 | 350 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 350 | narrow_integral>( | 229 | 350 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 350 | min_result, max_result, params); | 231 | 350 | } | 232 | 0 | return true; | 233 | 532 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIlEELb1ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIlEELb1ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 224 | CastParameters& params) { | 215 | 224 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 224 | if (from_scale < to_scale) { | 218 | 224 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 224 | narrow_integral>( | 220 | 224 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 224 | min_result, max_result, params); | 222 | 224 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 224 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 288 | CastParameters& params) { | 215 | 288 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 288 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 288 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 288 | } else { | 227 | 288 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 288 | narrow_integral>( | 229 | 288 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 288 | min_result, max_result, params); | 231 | 288 | } | 232 | 0 | return true; | 233 | 288 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 552 | CastParameters& params) { | 215 | 552 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 552 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 552 | } else if (from_scale == to_scale) { | 223 | 168 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 168 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 168 | max_result, params); | 226 | 384 | } else { | 227 | 384 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 384 | narrow_integral>( | 229 | 384 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 384 | min_result, max_result, params); | 231 | 384 | } | 232 | 0 | return true; | 233 | 552 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 224 | CastParameters& params) { | 215 | 224 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 224 | if (from_scale < to_scale) { | 218 | 224 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 224 | narrow_integral>( | 220 | 224 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 224 | min_result, max_result, params); | 222 | 224 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 224 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS_12Decimal128V3ELb0ELb0ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 378 | CastParameters& params) { | 215 | 378 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 378 | if (from_scale < to_scale) { | 218 | 120 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 120 | narrow_integral>( | 220 | 120 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 120 | min_result, max_result, params); | 222 | 258 | } else if (from_scale == to_scale) { | 223 | 74 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 74 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 74 | max_result, params); | 226 | 184 | } else { | 227 | 184 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 184 | narrow_integral>( | 229 | 184 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 184 | min_result, max_result, params); | 231 | 184 | } | 232 | 0 | return true; | 233 | 378 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS_12Decimal128V3ELb0ELb1ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 65 | CastParameters& params) { | 215 | 65 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 65 | if (from_scale < to_scale) { | 218 | 65 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 65 | narrow_integral>( | 220 | 65 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 65 | min_result, max_result, params); | 222 | 65 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 65 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS_12Decimal128V3ELb1ELb0ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS_12Decimal128V3ELb1ELb1ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 65 | CastParameters& params) { | 215 | 65 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 65 | if (from_scale < to_scale) { | 218 | 65 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 65 | narrow_integral>( | 220 | 65 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 65 | min_result, max_result, params); | 222 | 65 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 65 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS_12Decimal128V3ELb0ELb0ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 656 | CastParameters& params) { | 215 | 656 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 656 | if (from_scale < to_scale) { | 218 | 176 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 176 | narrow_integral>( | 220 | 176 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 176 | min_result, max_result, params); | 222 | 480 | } else if (from_scale == to_scale) { | 223 | 128 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 128 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 128 | max_result, params); | 226 | 352 | } else { | 227 | 352 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 352 | narrow_integral>( | 229 | 352 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 352 | min_result, max_result, params); | 231 | 352 | } | 232 | 0 | return true; | 233 | 656 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS_12Decimal128V3ELb0ELb1ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 116 | CastParameters& params) { | 215 | 116 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 116 | if (from_scale < to_scale) { | 218 | 116 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 116 | narrow_integral>( | 220 | 116 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 116 | min_result, max_result, params); | 222 | 116 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 116 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS_12Decimal128V3ELb1ELb0ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS_12Decimal128V3ELb1ELb1ES4_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 116 | CastParameters& params) { | 215 | 116 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 116 | if (from_scale < to_scale) { | 218 | 116 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 116 | narrow_integral>( | 220 | 116 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 116 | min_result, max_result, params); | 222 | 116 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 116 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ES2_Lb0ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKNS3_10NativeTypeESA_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 429 | CastParameters& params) { | 215 | 429 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 429 | if (from_scale < to_scale) { | 218 | 46 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 46 | narrow_integral>( | 220 | 46 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 46 | min_result, max_result, params); | 222 | 383 | } else if (from_scale == to_scale) { | 223 | 31 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 31 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 31 | max_result, params); | 226 | 352 | } else { | 227 | 352 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 352 | narrow_integral>( | 229 | 352 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 352 | min_result, max_result, params); | 231 | 352 | } | 232 | 0 | return true; | 233 | 429 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ES2_Lb0ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKNS3_10NativeTypeESA_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 209 | CastParameters& params) { | 215 | 209 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 209 | if (from_scale < to_scale) { | 218 | 70 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 70 | narrow_integral>( | 220 | 70 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 70 | min_result, max_result, params); | 222 | 139 | } else if (from_scale == to_scale) { | 223 | 43 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 43 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 43 | max_result, params); | 226 | 96 | } else { | 227 | 96 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 96 | narrow_integral>( | 229 | 96 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 96 | min_result, max_result, params); | 231 | 96 | } | 232 | 0 | return true; | 233 | 209 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ES2_Lb1ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKNS3_10NativeTypeESA_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ES2_Lb1ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKNS3_10NativeTypeESA_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 190 | CastParameters& params) { | 215 | 190 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 190 | if (from_scale < to_scale) { | 218 | 190 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 190 | narrow_integral>( | 220 | 190 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 190 | min_result, max_result, params); | 222 | 190 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 190 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 288 | CastParameters& params) { | 215 | 288 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 288 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 288 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 288 | } else { | 227 | 288 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 288 | narrow_integral>( | 229 | 288 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 288 | min_result, max_result, params); | 231 | 288 | } | 232 | 0 | return true; | 233 | 288 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 532 | CastParameters& params) { | 215 | 532 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 532 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 532 | } else if (from_scale == to_scale) { | 223 | 182 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 182 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 182 | max_result, params); | 226 | 350 | } else { | 227 | 350 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 350 | narrow_integral>( | 229 | 350 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 350 | min_result, max_result, params); | 231 | 350 | } | 232 | 0 | return true; | 233 | 532 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 224 | CastParameters& params) { | 215 | 224 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 224 | if (from_scale < to_scale) { | 218 | 224 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 224 | narrow_integral>( | 220 | 224 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 224 | min_result, max_result, params); | 222 | 224 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 224 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb0ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 378 | CastParameters& params) { | 215 | 378 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 378 | if (from_scale < to_scale) { | 218 | 120 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 120 | narrow_integral>( | 220 | 120 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 120 | min_result, max_result, params); | 222 | 258 | } else if (from_scale == to_scale) { | 223 | 74 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 74 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 74 | max_result, params); | 226 | 184 | } else { | 227 | 184 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 184 | narrow_integral>( | 229 | 184 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 184 | min_result, max_result, params); | 231 | 184 | } | 232 | 0 | return true; | 233 | 378 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb0ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 65 | CastParameters& params) { | 215 | 65 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 65 | if (from_scale < to_scale) { | 218 | 65 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 65 | narrow_integral>( | 220 | 65 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 65 | min_result, max_result, params); | 222 | 65 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 65 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb1ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb1ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 65 | CastParameters& params) { | 215 | 65 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 65 | if (from_scale < to_scale) { | 218 | 65 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 65 | narrow_integral>( | 220 | 65 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 65 | min_result, max_result, params); | 222 | 65 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 65 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb0ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 656 | CastParameters& params) { | 215 | 656 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 656 | if (from_scale < to_scale) { | 218 | 184 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 184 | narrow_integral>( | 220 | 184 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 184 | min_result, max_result, params); | 222 | 472 | } else if (from_scale == to_scale) { | 223 | 120 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 120 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 120 | max_result, params); | 226 | 352 | } else { | 227 | 352 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 352 | narrow_integral>( | 229 | 352 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 352 | min_result, max_result, params); | 231 | 352 | } | 232 | 0 | return true; | 233 | 656 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb0ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 116 | CastParameters& params) { | 215 | 116 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 116 | if (from_scale < to_scale) { | 218 | 116 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 116 | narrow_integral>( | 220 | 116 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 116 | min_result, max_result, params); | 222 | 116 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 116 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb1ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb1ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 116 | CastParameters& params) { | 215 | 116 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 116 | if (from_scale < to_scale) { | 218 | 116 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 116 | narrow_integral>( | 220 | 116 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 116 | min_result, max_result, params); | 222 | 116 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 116 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 656 | CastParameters& params) { | 215 | 656 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 656 | if (from_scale < to_scale) { | 218 | 176 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 176 | narrow_integral>( | 220 | 176 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 176 | min_result, max_result, params); | 222 | 480 | } else if (from_scale == to_scale) { | 223 | 128 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 128 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 128 | max_result, params); | 226 | 352 | } else { | 227 | 352 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 352 | narrow_integral>( | 229 | 352 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 352 | min_result, max_result, params); | 231 | 352 | } | 232 | 0 | return true; | 233 | 656 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 109 | CastParameters& params) { | 215 | 109 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 109 | if (from_scale < to_scale) { | 218 | 109 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 109 | narrow_integral>( | 220 | 109 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 109 | min_result, max_result, params); | 222 | 109 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 109 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 123 | CastParameters& params) { | 215 | 123 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 123 | if (from_scale < to_scale) { | 218 | 123 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 123 | narrow_integral>( | 220 | 123 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 123 | min_result, max_result, params); | 222 | 123 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 123 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKNS7_10NativeTypeESE_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 428 | CastParameters& params) { | 215 | 428 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 428 | if (from_scale < to_scale) { | 218 | 46 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 46 | narrow_integral>( | 220 | 46 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 46 | min_result, max_result, params); | 222 | 382 | } else if (from_scale == to_scale) { | 223 | 30 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 30 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 30 | max_result, params); | 226 | 352 | } else { | 227 | 352 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 352 | narrow_integral>( | 229 | 352 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 352 | min_result, max_result, params); | 231 | 352 | } | 232 | 0 | return true; | 233 | 428 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKNS7_10NativeTypeESE_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 182 | CastParameters& params) { | 215 | 182 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 182 | if (from_scale < to_scale) { | 218 | 44 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 44 | narrow_integral>( | 220 | 44 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 44 | min_result, max_result, params); | 222 | 138 | } else if (from_scale == to_scale) { | 223 | 42 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 42 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 42 | max_result, params); | 226 | 96 | } else { | 227 | 96 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 96 | narrow_integral>( | 229 | 96 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 96 | min_result, max_result, params); | 231 | 96 | } | 232 | 0 | return true; | 233 | 182 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKNS7_10NativeTypeESE_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKNS7_10NativeTypeESE_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 210 | CastParameters& params) { | 215 | 210 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 210 | if (from_scale < to_scale) { | 218 | 210 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 210 | narrow_integral>( | 220 | 210 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 210 | min_result, max_result, params); | 222 | 210 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 210 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIiEELb0ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 36 | CastParameters& params) { | 215 | 36 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 36 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 36 | } else if (from_scale == to_scale) { | 223 | 4 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 4 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 4 | max_result, params); | 226 | 32 | } else { | 227 | 32 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 32 | narrow_integral>( | 229 | 32 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 32 | min_result, max_result, params); | 231 | 32 | } | 232 | 0 | return true; | 233 | 36 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIiEELb0ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 470 | CastParameters& params) { | 215 | 470 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 470 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 470 | } else if (from_scale == to_scale) { | 223 | 35 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 35 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 35 | max_result, params); | 226 | 435 | } else { | 227 | 435 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 435 | narrow_integral>( | 229 | 435 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 435 | min_result, max_result, params); | 231 | 435 | } | 232 | 0 | return true; | 233 | 470 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIiEELb1ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIiEELb1ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE _ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIlEELb0ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 131 | CastParameters& params) { | 215 | 131 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 131 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 131 | } else if (from_scale == to_scale) { | 223 | 7 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 7 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 7 | max_result, params); | 226 | 124 | } else { | 227 | 124 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 124 | narrow_integral>( | 229 | 124 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 124 | min_result, max_result, params); | 231 | 124 | } | 232 | 0 | return true; | 233 | 131 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIlEELb0ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 414 | CastParameters& params) { | 215 | 414 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 414 | if (from_scale < to_scale) { | 218 | 0 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 0 | narrow_integral>( | 220 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 0 | min_result, max_result, params); | 222 | 414 | } else if (from_scale == to_scale) { | 223 | 60 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 60 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 60 | max_result, params); | 226 | 354 | } else { | 227 | 354 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 354 | narrow_integral>( | 229 | 354 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 354 | min_result, max_result, params); | 231 | 354 | } | 232 | 0 | return true; | 233 | 414 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIlEELb1ELb0ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 15 | CastParameters& params) { | 215 | 15 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 15 | if (from_scale < to_scale) { | 218 | 15 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 15 | narrow_integral>( | 220 | 15 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 15 | min_result, max_result, params); | 222 | 15 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 15 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIlEELb1ELb1ES2_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 130 | CastParameters& params) { | 215 | 130 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 130 | if (from_scale < to_scale) { | 218 | 130 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 130 | narrow_integral>( | 220 | 130 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 130 | min_result, max_result, params); | 222 | 130 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 130 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_12Decimal128V3ELb0ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 375 | CastParameters& params) { | 215 | 375 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 375 | if (from_scale < to_scale) { | 218 | 11 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 11 | narrow_integral>( | 220 | 11 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 11 | min_result, max_result, params); | 222 | 364 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 364 | } else { | 227 | 364 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 364 | narrow_integral>( | 229 | 364 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 364 | min_result, max_result, params); | 231 | 364 | } | 232 | 0 | return true; | 233 | 375 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_12Decimal128V3ELb0ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 145 | CastParameters& params) { | 215 | 145 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 145 | if (from_scale < to_scale) { | 218 | 95 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 95 | narrow_integral>( | 220 | 95 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 95 | min_result, max_result, params); | 222 | 95 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 50 | } else { | 227 | 50 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 50 | narrow_integral>( | 229 | 50 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 50 | min_result, max_result, params); | 231 | 50 | } | 232 | 0 | return true; | 233 | 145 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_12Decimal128V3ELb1ELb0ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 11 | CastParameters& params) { | 215 | 11 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 11 | if (from_scale < to_scale) { | 218 | 11 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 11 | narrow_integral>( | 220 | 11 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 11 | min_result, max_result, params); | 222 | 11 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 11 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_12Decimal128V3ELb1ELb1ES3_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 95 | CastParameters& params) { | 215 | 95 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 95 | if (from_scale < to_scale) { | 218 | 95 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 95 | narrow_integral>( | 220 | 95 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 95 | min_result, max_result, params); | 222 | 95 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 95 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 423 | CastParameters& params) { | 215 | 423 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 423 | if (from_scale < to_scale) { | 218 | 11 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 11 | narrow_integral>( | 220 | 11 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 11 | min_result, max_result, params); | 222 | 412 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 412 | } else { | 227 | 412 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 412 | narrow_integral>( | 229 | 412 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 412 | min_result, max_result, params); | 231 | 412 | } | 232 | 0 | return true; | 233 | 423 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 95 | CastParameters& params) { | 215 | 95 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 95 | if (from_scale < to_scale) { | 218 | 95 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 95 | narrow_integral>( | 220 | 95 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 95 | min_result, max_result, params); | 222 | 95 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 95 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 11 | CastParameters& params) { | 215 | 11 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 11 | if (from_scale < to_scale) { | 218 | 11 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 11 | narrow_integral>( | 220 | 11 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 11 | min_result, max_result, params); | 222 | 11 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 11 | } |
_ZN5doris13CastToDecimal13_from_decimalINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES7_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RKNT3_10NativeTypeERNS_14CastParametersE Line | Count | Source | 214 | 95 | CastParameters& params) { | 215 | 95 | using MaxNativeType = typename MaxFieldType::NativeType; | 216 | | | 217 | 95 | if (from_scale < to_scale) { | 218 | 95 | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, | 219 | 95 | narrow_integral>( | 220 | 95 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 221 | 95 | min_result, max_result, params); | 222 | 95 | } else if (from_scale == to_scale) { | 223 | 0 | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, narrow_integral>( | 224 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, min_result, | 225 | 0 | max_result, params); | 226 | 0 | } else { | 227 | 0 | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, | 228 | 0 | narrow_integral>( | 229 | 0 | from, from_precision, from_scale, to, to_precision, to_scale, scale_multiplier, | 230 | 0 | min_result, max_result, params); | 231 | 0 | } | 232 | 0 | return true; | 233 | 95 | } |
|
234 | | |
235 | | template <typename FromCppT, typename ToCppT> |
236 | | requires(IsDecimalNumber<ToCppT> && IsCppTypeFloat<FromCppT>) |
237 | | static inline bool _from_float(const FromCppT& from, ToCppT& to, UInt32 to_precision, |
238 | | UInt32 to_scale, |
239 | | const typename ToCppT::NativeType& scale_multiplier, |
240 | | const typename ToCppT::NativeType& min_result, |
241 | | const typename ToCppT::NativeType& max_result, |
242 | 3.57k | CastParameters& params) { |
243 | 3.57k | if (!std::isfinite(from)) { |
244 | 196 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, |
245 | 196 | "Decimal convert overflow. Cannot convert infinity or NaN " |
246 | 196 | "to decimal"); |
247 | 196 | return false; |
248 | 196 | } |
249 | 3.38k | auto overflow = [&]() { |
250 | 168 | if (params.is_strict) { |
251 | 84 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, |
252 | 84 | to_scale); |
253 | 84 | } |
254 | 168 | return false; |
255 | 168 | }; _ZZN5doris13CastToDecimal11_from_floatIdNS_7DecimalIiEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 24 | auto overflow = [&]() { | 250 | 24 | if (params.is_strict) { | 251 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 12 | to_scale); | 253 | 12 | } | 254 | 24 | return false; | 255 | 24 | }; |
_ZZN5doris13CastToDecimal11_from_floatIfNS_7DecimalIiEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 12 | auto overflow = [&]() { | 250 | 12 | if (params.is_strict) { | 251 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 6 | to_scale); | 253 | 6 | } | 254 | 12 | return false; | 255 | 12 | }; |
_ZZN5doris13CastToDecimal11_from_floatIdNS_7DecimalIlEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 28 | auto overflow = [&]() { | 250 | 28 | if (params.is_strict) { | 251 | 14 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 14 | to_scale); | 253 | 14 | } | 254 | 28 | return false; | 255 | 28 | }; |
_ZZN5doris13CastToDecimal11_from_floatIfNS_7DecimalIlEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 12 | auto overflow = [&]() { | 250 | 12 | if (params.is_strict) { | 251 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 6 | to_scale); | 253 | 6 | } | 254 | 12 | return false; | 255 | 12 | }; |
_ZZN5doris13CastToDecimal11_from_floatIdNS_12Decimal128V3EQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 36 | auto overflow = [&]() { | 250 | 36 | if (params.is_strict) { | 251 | 18 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 18 | to_scale); | 253 | 18 | } | 254 | 36 | return false; | 255 | 36 | }; |
_ZZN5doris13CastToDecimal11_from_floatIfNS_12Decimal128V3EQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 12 | auto overflow = [&]() { | 250 | 12 | if (params.is_strict) { | 251 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 6 | to_scale); | 253 | 6 | } | 254 | 12 | return false; | 255 | 12 | }; |
_ZZN5doris13CastToDecimal11_from_floatIdNS_7DecimalIN4wide7integerILm256EiEEEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS8_RS7_jjRKNS7_10NativeTypeESE_SE_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 36 | auto overflow = [&]() { | 250 | 36 | if (params.is_strict) { | 251 | 18 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 18 | to_scale); | 253 | 18 | } | 254 | 36 | return false; | 255 | 36 | }; |
_ZZN5doris13CastToDecimal11_from_floatIfNS_7DecimalIN4wide7integerILm256EiEEEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS8_RS7_jjRKNS7_10NativeTypeESE_SE_RNS_14CastParametersEENKUlvE_clEv Line | Count | Source | 249 | 8 | auto overflow = [&]() { | 250 | 8 | if (params.is_strict) { | 251 | 4 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 4 | to_scale); | 253 | 4 | } | 254 | 8 | return false; | 255 | 8 | }; |
Unexecuted instantiation: _ZZN5doris13CastToDecimal11_from_floatIdNS_14DecimalV2ValueEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersEENKUlvE_clEv Unexecuted instantiation: _ZZN5doris13CastToDecimal11_from_floatIfNS_14DecimalV2ValueEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersEENKUlvE_clEv |
256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant |
257 | | // folding for halfway cases such as +/-0.15 at scale 1. |
258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round |
259 | | // exactly representable odd integers above 2^52 to the next even integer in double. |
260 | 3.38k | const double tmp = |
261 | 3.38k | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); |
262 | 3.38k | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { |
263 | 116 | return overflow(); |
264 | 116 | } |
265 | | |
266 | 3.26k | using NativeType = typename ToCppT::NativeType; |
267 | 3.26k | if (to_scale > 0) { |
268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: |
269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. |
270 | 2.92k | const NativeType integral_limit = |
271 | 2.92k | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); |
272 | 2.92k | const auto integral = static_cast<NativeType>(from); |
273 | 2.92k | if (integral <= -integral_limit || integral >= integral_limit) { |
274 | 40 | return overflow(); |
275 | 40 | } |
276 | 2.92k | } |
277 | | // Every supported decimal precision leaves room below the native integer limit, even when |
278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 |
279 | | // significand directly, so this also preserves every integer bit represented by tmp. |
280 | 3.22k | auto result = static_cast<NativeType>(tmp); |
281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer |
282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. |
283 | 3.22k | if (result < min_result || result > max_result) { |
284 | 12 | return overflow(); |
285 | 12 | } |
286 | 3.21k | if constexpr (IsDecimal128V2<ToCppT>) { |
287 | 4 | to = DecimalV2Value(result); |
288 | 3.20k | } else { |
289 | 3.20k | to.value = result; |
290 | 3.20k | } |
291 | 3.21k | return true; |
292 | 3.22k | } _ZN5doris13CastToDecimal11_from_floatIdNS_7DecimalIiEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersE Line | Count | Source | 242 | 485 | CastParameters& params) { | 243 | 485 | if (!std::isfinite(from)) { | 244 | 24 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 24 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 24 | "to decimal"); | 247 | 24 | return false; | 248 | 24 | } | 249 | 461 | auto overflow = [&]() { | 250 | 461 | if (params.is_strict) { | 251 | 461 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 461 | to_scale); | 253 | 461 | } | 254 | 461 | return false; | 255 | 461 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 461 | const double tmp = | 261 | 461 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 461 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 24 | return overflow(); | 264 | 24 | } | 265 | | | 266 | 437 | using NativeType = typename ToCppT::NativeType; | 267 | 437 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 385 | const NativeType integral_limit = | 271 | 385 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 385 | const auto integral = static_cast<NativeType>(from); | 273 | 385 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 0 | return overflow(); | 275 | 0 | } | 276 | 385 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 437 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 437 | if (result < min_result || result > max_result) { | 284 | 0 | return overflow(); | 285 | 0 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 437 | } else { | 289 | 437 | to.value = result; | 290 | 437 | } | 291 | 437 | return true; | 292 | 437 | } |
_ZN5doris13CastToDecimal11_from_floatIfNS_7DecimalIiEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersE Line | Count | Source | 242 | 433 | CastParameters& params) { | 243 | 433 | if (!std::isfinite(from)) { | 244 | 24 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 24 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 24 | "to decimal"); | 247 | 24 | return false; | 248 | 24 | } | 249 | 409 | auto overflow = [&]() { | 250 | 409 | if (params.is_strict) { | 251 | 409 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 409 | to_scale); | 253 | 409 | } | 254 | 409 | return false; | 255 | 409 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 409 | const double tmp = | 261 | 409 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 409 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 12 | return overflow(); | 264 | 12 | } | 265 | | | 266 | 397 | using NativeType = typename ToCppT::NativeType; | 267 | 397 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 369 | const NativeType integral_limit = | 271 | 369 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 369 | const auto integral = static_cast<NativeType>(from); | 273 | 369 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 0 | return overflow(); | 275 | 0 | } | 276 | 369 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 397 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 397 | if (result < min_result || result > max_result) { | 284 | 0 | return overflow(); | 285 | 0 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 397 | } else { | 289 | 397 | to.value = result; | 290 | 397 | } | 291 | 397 | return true; | 292 | 397 | } |
_ZN5doris13CastToDecimal11_from_floatIdNS_7DecimalIlEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersE Line | Count | Source | 242 | 468 | CastParameters& params) { | 243 | 468 | if (!std::isfinite(from)) { | 244 | 24 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 24 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 24 | "to decimal"); | 247 | 24 | return false; | 248 | 24 | } | 249 | 444 | auto overflow = [&]() { | 250 | 444 | if (params.is_strict) { | 251 | 444 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 444 | to_scale); | 253 | 444 | } | 254 | 444 | return false; | 255 | 444 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 444 | const double tmp = | 261 | 444 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 444 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 20 | return overflow(); | 264 | 20 | } | 265 | | | 266 | 424 | using NativeType = typename ToCppT::NativeType; | 267 | 424 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 372 | const NativeType integral_limit = | 271 | 372 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 372 | const auto integral = static_cast<NativeType>(from); | 273 | 372 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 4 | return overflow(); | 275 | 4 | } | 276 | 372 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 420 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 420 | if (result < min_result || result > max_result) { | 284 | 4 | return overflow(); | 285 | 4 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 416 | } else { | 289 | 416 | to.value = result; | 290 | 416 | } | 291 | 416 | return true; | 292 | 420 | } |
_ZN5doris13CastToDecimal11_from_floatIfNS_7DecimalIlEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS5_RS4_jjRKNS4_10NativeTypeESB_SB_RNS_14CastParametersE Line | Count | Source | 242 | 384 | CastParameters& params) { | 243 | 384 | if (!std::isfinite(from)) { | 244 | 24 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 24 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 24 | "to decimal"); | 247 | 24 | return false; | 248 | 24 | } | 249 | 360 | auto overflow = [&]() { | 250 | 360 | if (params.is_strict) { | 251 | 360 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 360 | to_scale); | 253 | 360 | } | 254 | 360 | return false; | 255 | 360 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 360 | const double tmp = | 261 | 360 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 360 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 8 | return overflow(); | 264 | 8 | } | 265 | | | 266 | 352 | using NativeType = typename ToCppT::NativeType; | 267 | 352 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 316 | const NativeType integral_limit = | 271 | 316 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 316 | const auto integral = static_cast<NativeType>(from); | 273 | 316 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 4 | return overflow(); | 275 | 4 | } | 276 | 316 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 348 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 348 | if (result < min_result || result > max_result) { | 284 | 0 | return overflow(); | 285 | 0 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 348 | } else { | 289 | 348 | to.value = result; | 290 | 348 | } | 291 | 348 | return true; | 292 | 348 | } |
_ZN5doris13CastToDecimal11_from_floatIdNS_12Decimal128V3EQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersE Line | Count | Source | 242 | 432 | CastParameters& params) { | 243 | 432 | if (!std::isfinite(from)) { | 244 | 24 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 24 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 24 | "to decimal"); | 247 | 24 | return false; | 248 | 24 | } | 249 | 408 | auto overflow = [&]() { | 250 | 408 | if (params.is_strict) { | 251 | 408 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 408 | to_scale); | 253 | 408 | } | 254 | 408 | return false; | 255 | 408 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 408 | const double tmp = | 261 | 408 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 408 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 20 | return overflow(); | 264 | 20 | } | 265 | | | 266 | 388 | using NativeType = typename ToCppT::NativeType; | 267 | 388 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 328 | const NativeType integral_limit = | 271 | 328 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 328 | const auto integral = static_cast<NativeType>(from); | 273 | 328 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 12 | return overflow(); | 275 | 12 | } | 276 | 328 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 376 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 376 | if (result < min_result || result > max_result) { | 284 | 4 | return overflow(); | 285 | 4 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 372 | } else { | 289 | 372 | to.value = result; | 290 | 372 | } | 291 | 372 | return true; | 292 | 376 | } |
_ZN5doris13CastToDecimal11_from_floatIfNS_12Decimal128V3EQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersE Line | Count | Source | 242 | 448 | CastParameters& params) { | 243 | 448 | if (!std::isfinite(from)) { | 244 | 24 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 24 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 24 | "to decimal"); | 247 | 24 | return false; | 248 | 24 | } | 249 | 424 | auto overflow = [&]() { | 250 | 424 | if (params.is_strict) { | 251 | 424 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 424 | to_scale); | 253 | 424 | } | 254 | 424 | return false; | 255 | 424 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 424 | const double tmp = | 261 | 424 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 424 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 8 | return overflow(); | 264 | 8 | } | 265 | | | 266 | 416 | using NativeType = typename ToCppT::NativeType; | 267 | 416 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 380 | const NativeType integral_limit = | 271 | 380 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 380 | const auto integral = static_cast<NativeType>(from); | 273 | 380 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 4 | return overflow(); | 275 | 4 | } | 276 | 380 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 412 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 412 | if (result < min_result || result > max_result) { | 284 | 0 | return overflow(); | 285 | 0 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 412 | } else { | 289 | 412 | to.value = result; | 290 | 412 | } | 291 | 412 | return true; | 292 | 412 | } |
_ZN5doris13CastToDecimal11_from_floatIdNS_7DecimalIN4wide7integerILm256EiEEEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS8_RS7_jjRKNS7_10NativeTypeESE_SE_RNS_14CastParametersE Line | Count | Source | 242 | 494 | CastParameters& params) { | 243 | 494 | if (!std::isfinite(from)) { | 244 | 24 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 24 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 24 | "to decimal"); | 247 | 24 | return false; | 248 | 24 | } | 249 | 470 | auto overflow = [&]() { | 250 | 470 | if (params.is_strict) { | 251 | 470 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 470 | to_scale); | 253 | 470 | } | 254 | 470 | return false; | 255 | 470 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 470 | const double tmp = | 261 | 470 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 470 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 20 | return overflow(); | 264 | 20 | } | 265 | | | 266 | 450 | using NativeType = typename ToCppT::NativeType; | 267 | 450 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 394 | const NativeType integral_limit = | 271 | 394 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 394 | const auto integral = static_cast<NativeType>(from); | 273 | 394 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 12 | return overflow(); | 275 | 12 | } | 276 | 394 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 438 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 438 | if (result < min_result || result > max_result) { | 284 | 4 | return overflow(); | 285 | 4 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 434 | } else { | 289 | 434 | to.value = result; | 290 | 434 | } | 291 | 434 | return true; | 292 | 438 | } |
_ZN5doris13CastToDecimal11_from_floatIfNS_7DecimalIN4wide7integerILm256EiEEEEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS8_RS7_jjRKNS7_10NativeTypeESE_SE_RNS_14CastParametersE Line | Count | Source | 242 | 428 | CastParameters& params) { | 243 | 428 | if (!std::isfinite(from)) { | 244 | 28 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 28 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 28 | "to decimal"); | 247 | 28 | return false; | 248 | 28 | } | 249 | 400 | auto overflow = [&]() { | 250 | 400 | if (params.is_strict) { | 251 | 400 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 400 | to_scale); | 253 | 400 | } | 254 | 400 | return false; | 255 | 400 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 400 | const double tmp = | 261 | 400 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 400 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 4 | return overflow(); | 264 | 4 | } | 265 | | | 266 | 396 | using NativeType = typename ToCppT::NativeType; | 267 | 396 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 380 | const NativeType integral_limit = | 271 | 380 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 380 | const auto integral = static_cast<NativeType>(from); | 273 | 380 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 4 | return overflow(); | 275 | 4 | } | 276 | 380 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 392 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 392 | if (result < min_result || result > max_result) { | 284 | 0 | return overflow(); | 285 | 0 | } | 286 | | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | | to = DecimalV2Value(result); | 288 | 392 | } else { | 289 | 392 | to.value = result; | 290 | 392 | } | 291 | 392 | return true; | 292 | 392 | } |
_ZN5doris13CastToDecimal11_from_floatIdNS_14DecimalV2ValueEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersE Line | Count | Source | 242 | 4 | CastParameters& params) { | 243 | 4 | if (!std::isfinite(from)) { | 244 | 0 | params.status = Status(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, | 245 | 0 | "Decimal convert overflow. Cannot convert infinity or NaN " | 246 | 0 | "to decimal"); | 247 | 0 | return false; | 248 | 0 | } | 249 | 4 | auto overflow = [&]() { | 250 | 4 | if (params.is_strict) { | 251 | 4 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, "float/double", to_precision, | 252 | 4 | to_scale); | 253 | 4 | } | 254 | 4 | return false; | 255 | 4 | }; | 256 | | // Use binary64 arithmetic for every decimal backing type. This also matches FE constant | 257 | | // folding for halfway cases such as +/-0.15 at scale 1. | 258 | | // Round before checking the inclusive decimal bounds. Adding 0.5 would itself round | 259 | | // exactly representable odd integers above 2^52 to the next even integer in double. | 260 | 4 | const double tmp = | 261 | 4 | std::round(static_cast<double>(from) * static_cast<double>(scale_multiplier)); | 262 | 4 | if (tmp < static_cast<double>(min_result) || tmp > static_cast<double>(max_result)) { | 263 | 0 | return overflow(); | 264 | 0 | } | 265 | | | 266 | 4 | using NativeType = typename ToCppT::NativeType; | 267 | 4 | if (to_scale > 0) { | 268 | | // Scaling can round an out-of-range integer back inside the decimal bounds: | 269 | | // double(10 * 10^37) is below 10^38. Check the original integer part exactly. | 270 | 4 | const NativeType integral_limit = | 271 | 4 | DataTypeDecimal<ToCppT::PType>::get_scale_multiplier(to_precision - to_scale); | 272 | 4 | const auto integral = static_cast<NativeType>(from); | 273 | 4 | if (integral <= -integral_limit || integral >= integral_limit) { | 274 | 0 | return overflow(); | 275 | 0 | } | 276 | 4 | } | 277 | | // Every supported decimal precision leaves room below the native integer limit, even when | 278 | | // converting max_result to floating point rounds it up. Int256 reconstructs the binary64 | 279 | | // significand directly, so this also preserves every integer bit represented by tmp. | 280 | 4 | auto result = static_cast<NativeType>(tmp); | 281 | | // Floating point cannot represent all decimal bounds exactly. Recheck in integer | 282 | | // arithmetic to reject a rounded-up bound such as double(10^18 - 1) == 10^18. | 283 | 4 | if (result < min_result || result > max_result) { | 284 | 0 | return overflow(); | 285 | 0 | } | 286 | 4 | if constexpr (IsDecimal128V2<ToCppT>) { | 287 | 4 | to = DecimalV2Value(result); | 288 | | } else { | 289 | | to.value = result; | 290 | | } | 291 | 4 | return true; | 292 | 4 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal11_from_floatIfNS_14DecimalV2ValueEQaa15IsDecimalNumberIT0_E14IsCppTypeFloatIT_EEEbRKS4_RS3_jjRKNS3_10NativeTypeESA_SA_RNS_14CastParametersE |
293 | | |
294 | | template <typename FromCppT, typename ToCppT, |
295 | | typename MaxFieldType = std::conditional_t< |
296 | | (sizeof(FromCppT) == sizeof(ToCppT)) && |
297 | | (std::is_same_v<ToCppT, Decimal128V3> || |
298 | | std::is_same_v<FromCppT, Decimal128V3>), |
299 | | Decimal128V3, |
300 | | std::conditional_t<(sizeof(FromCppT) > sizeof(ToCppT)), FromCppT, ToCppT>>> |
301 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
302 | | static inline bool from_decimal(const FromCppT& from, const UInt32 from_precision, |
303 | | const UInt32 from_scale, UInt32 from_original_precision, |
304 | | UInt32 from_original_scale, ToCppT& to, UInt32 to_precision, |
305 | | UInt32 to_scale, CastParameters& params) { |
306 | | return _from_decimalv2<FromCppT, ToCppT, MaxFieldType>( |
307 | | from, from_precision, from_scale, from_original_precision, from_original_scale, to, |
308 | | to_precision, to_scale, params); |
309 | | } |
310 | | |
311 | | template <typename FromCppT, typename ToCppT, |
312 | | typename MaxFieldType = std::conditional_t< |
313 | | (sizeof(FromCppT) == sizeof(ToCppT)) && |
314 | | (std::is_same_v<ToCppT, Decimal128V3> || |
315 | | std::is_same_v<FromCppT, Decimal128V3>), |
316 | | Decimal128V3, |
317 | | std::conditional_t<(sizeof(FromCppT) > sizeof(ToCppT)), FromCppT, ToCppT>>> |
318 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
319 | | static inline bool _from_decimalv2(const FromCppT& from, const UInt32 from_precision, |
320 | | const UInt32 from_scale, UInt32 from_original_precision, |
321 | | UInt32 from_original_scale, ToCppT& to, UInt32 to_precision, |
322 | | UInt32 to_scale, CastParameters& params) { |
323 | | using MaxNativeType = typename MaxFieldType::NativeType; |
324 | | |
325 | | auto from_max_int_digit_count = from_original_precision - from_original_scale; |
326 | | auto to_max_int_digit_count = to_precision - to_scale; |
327 | | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || |
328 | | (to_max_int_digit_count == from_max_int_digit_count && |
329 | | to_scale < from_original_scale); |
330 | | |
331 | | constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToCppT::NativeType>(); |
332 | | bool multiply_may_overflow = false; |
333 | | if (to_scale > from_scale) { |
334 | | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; |
335 | | } |
336 | | |
337 | | typename ToCppT::NativeType max_result = |
338 | | DataTypeDecimal<ToCppT::PType>::get_max_digits_number(to_precision); |
339 | | typename ToCppT::NativeType min_result = -max_result; |
340 | | |
341 | | return std::visit( |
342 | | [&](auto multiply_may_overflow, auto narrow_integral) { |
343 | | if (from_scale < to_scale) { |
344 | | MaxNativeType multiplier = |
345 | | DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier( |
346 | | to_scale - from_scale); |
347 | | return _from_decimal_smaller_scale<FromCppT, ToCppT, multiply_may_overflow, |
348 | | narrow_integral>( |
349 | | from, from_precision, from_scale, to, to_precision, to_scale, |
350 | | multiplier, min_result, max_result, params); |
351 | | } else if (from_scale == to_scale) { |
352 | | return _from_decimal_same_scale<FromCppT, ToCppT, MaxNativeType, |
353 | | narrow_integral>( |
354 | | from, from_precision, from_scale, to, to_precision, to_scale, |
355 | | min_result, max_result, params); |
356 | | } else { |
357 | | MaxNativeType multiplier = |
358 | | DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier( |
359 | | from_scale - to_scale); |
360 | | return _from_decimal_bigger_scale<FromCppT, ToCppT, multiply_may_overflow, |
361 | | narrow_integral>( |
362 | | from, from_precision, from_scale, to, to_precision, to_scale, |
363 | | multiplier, min_result, max_result, params); |
364 | | } |
365 | | return true; |
366 | | }, |
367 | | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral)); |
368 | | } |
369 | | |
370 | | template <typename FromCppT, typename ToCppT, bool multiply_may_overflow, bool narrow_integral, |
371 | | typename MaxNativeType = |
372 | | std::conditional_t<(sizeof(FromCppT) > sizeof(typename ToCppT::NativeType)), |
373 | | FromCppT, typename ToCppT::NativeType>> |
374 | | requires(IsDecimalNumber<ToCppT> && !IsDecimal128V2<ToCppT> && |
375 | | (IsCppTypeInt<FromCppT> || std::is_same_v<FromCppT, UInt8>)) |
376 | | static inline bool _from_int(const FromCppT& from, ToCppT& to, UInt32 precision, UInt32 scale, |
377 | | const MaxNativeType& scale_multiplier, |
378 | | const typename ToCppT::NativeType& min_result, |
379 | | const typename ToCppT::NativeType& max_result, |
380 | 2.88k | CastParameters& params) { |
381 | 2.88k | MaxNativeType tmp; |
382 | 2.88k | if constexpr (multiply_may_overflow) { |
383 | 1.05k | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { |
384 | 154 | if (params.is_strict) { |
385 | 76 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, |
386 | 76 | precision, scale); |
387 | 76 | } |
388 | 154 | return false; |
389 | 154 | } |
390 | 901 | if constexpr (narrow_integral) { |
391 | 901 | if (tmp < min_result || tmp > max_result) { |
392 | 177 | if (params.is_strict) { |
393 | 88 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
394 | 88 | from, int_type_name<FromCppT>, precision, scale); |
395 | 88 | } |
396 | 177 | return false; |
397 | 177 | } |
398 | 901 | } |
399 | 724 | to.value = static_cast<typename ToCppT::NativeType>(tmp); |
400 | 1.82k | } else { |
401 | 1.82k | tmp = scale_multiplier * from; |
402 | 1.82k | if constexpr (narrow_integral) { |
403 | 1.42k | if (tmp < min_result || tmp > max_result) { |
404 | 433 | if (params.is_strict) { |
405 | 216 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
406 | 216 | from, int_type_name<FromCppT>, precision, scale); |
407 | 216 | } |
408 | 433 | return false; |
409 | 433 | } |
410 | 1.42k | } |
411 | 988 | to.value = static_cast<typename ToCppT::NativeType>(tmp); |
412 | 1.82k | } |
413 | | |
414 | 0 | return true; |
415 | 2.88k | } _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIiEELb0ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 8 | CastParameters& params) { | 381 | 8 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 8 | } else { | 401 | 8 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 8 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 8 | } | 413 | | | 414 | 8 | return true; | 415 | 8 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIiEELb0ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIiEELb1ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIiEELb1ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 4 | CastParameters& params) { | 381 | 4 | MaxNativeType tmp; | 382 | 4 | if constexpr (multiply_may_overflow) { | 383 | 4 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 0 | if (params.is_strict) { | 385 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 0 | precision, scale); | 387 | 0 | } | 388 | 0 | return false; | 389 | 0 | } | 390 | 4 | if constexpr (narrow_integral) { | 391 | 4 | if (tmp < min_result || tmp > max_result) { | 392 | 2 | if (params.is_strict) { | 393 | 1 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 1 | from, int_type_name<FromCppT>, precision, scale); | 395 | 1 | } | 396 | 2 | return false; | 397 | 2 | } | 398 | 4 | } | 399 | 2 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 4 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIiEELb0ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 19 | CastParameters& params) { | 381 | 19 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 19 | } else { | 401 | 19 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 19 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 19 | } | 413 | | | 414 | 19 | return true; | 415 | 19 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIiEELb0ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 74 | CastParameters& params) { | 381 | 74 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 74 | } else { | 401 | 74 | tmp = scale_multiplier * from; | 402 | 74 | if constexpr (narrow_integral) { | 403 | 74 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 74 | } | 411 | 50 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 74 | } | 413 | | | 414 | 0 | return true; | 415 | 74 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIiEELb1ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIiEELb1ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIiEELb0ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 18 | CastParameters& params) { | 381 | 18 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 18 | } else { | 401 | 18 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 18 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 18 | } | 413 | | | 414 | 18 | return true; | 415 | 18 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIiEELb0ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 109 | CastParameters& params) { | 381 | 109 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 109 | } else { | 401 | 109 | tmp = scale_multiplier * from; | 402 | 109 | if constexpr (narrow_integral) { | 403 | 109 | if (tmp < min_result || tmp > max_result) { | 404 | 33 | if (params.is_strict) { | 405 | 16 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 16 | from, int_type_name<FromCppT>, precision, scale); | 407 | 16 | } | 408 | 33 | return false; | 409 | 33 | } | 410 | 109 | } | 411 | 76 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 109 | } | 413 | | | 414 | 0 | return true; | 415 | 109 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIiEELb1ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIiEELb1ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIiEELb0ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIiEELb0ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 90 | CastParameters& params) { | 381 | 90 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 90 | } else { | 401 | 90 | tmp = scale_multiplier * from; | 402 | 90 | if constexpr (narrow_integral) { | 403 | 90 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 90 | } | 411 | 66 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 90 | } | 413 | | | 414 | 0 | return true; | 415 | 90 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIiEELb1ELb0EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIiEELb1ELb1EiQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 109 | CastParameters& params) { | 381 | 109 | MaxNativeType tmp; | 382 | 109 | if constexpr (multiply_may_overflow) { | 383 | 109 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 17 | if (params.is_strict) { | 385 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 8 | precision, scale); | 387 | 8 | } | 388 | 17 | return false; | 389 | 17 | } | 390 | 92 | if constexpr (narrow_integral) { | 391 | 92 | if (tmp < min_result || tmp > max_result) { | 392 | 16 | if (params.is_strict) { | 393 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 8 | from, int_type_name<FromCppT>, precision, scale); | 395 | 8 | } | 396 | 16 | return false; | 397 | 16 | } | 398 | 92 | } | 399 | 76 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 109 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIiEELb0ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIiEELb0ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 90 | CastParameters& params) { | 381 | 90 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 90 | } else { | 401 | 90 | tmp = scale_multiplier * from; | 402 | 90 | if constexpr (narrow_integral) { | 403 | 90 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 90 | } | 411 | 66 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 90 | } | 413 | | | 414 | 0 | return true; | 415 | 90 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIiEELb1ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIiEELb1ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 109 | CastParameters& params) { | 381 | 109 | MaxNativeType tmp; | 382 | 109 | if constexpr (multiply_may_overflow) { | 383 | 109 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 17 | if (params.is_strict) { | 385 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 8 | precision, scale); | 387 | 8 | } | 388 | 17 | return false; | 389 | 17 | } | 390 | 92 | if constexpr (narrow_integral) { | 391 | 92 | if (tmp < min_result || tmp > max_result) { | 392 | 16 | if (params.is_strict) { | 393 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 8 | from, int_type_name<FromCppT>, precision, scale); | 395 | 8 | } | 396 | 16 | return false; | 397 | 16 | } | 398 | 92 | } | 399 | 76 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 109 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIiEELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIiEELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 90 | CastParameters& params) { | 381 | 90 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 90 | } else { | 401 | 90 | tmp = scale_multiplier * from; | 402 | 90 | if constexpr (narrow_integral) { | 403 | 90 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 90 | } | 411 | 66 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 90 | } | 413 | | | 414 | 0 | return true; | 415 | 90 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIiEELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIiEELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 109 | CastParameters& params) { | 381 | 109 | MaxNativeType tmp; | 382 | 109 | if constexpr (multiply_may_overflow) { | 383 | 109 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 16 | if (params.is_strict) { | 385 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 8 | precision, scale); | 387 | 8 | } | 388 | 16 | return false; | 389 | 16 | } | 390 | 93 | if constexpr (narrow_integral) { | 391 | 93 | if (tmp < min_result || tmp > max_result) { | 392 | 17 | if (params.is_strict) { | 393 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 8 | from, int_type_name<FromCppT>, precision, scale); | 395 | 8 | } | 396 | 17 | return false; | 397 | 17 | } | 398 | 93 | } | 399 | 76 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 109 | } |
_ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIlEELb0ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 6 | CastParameters& params) { | 381 | 6 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 6 | } else { | 401 | 6 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 6 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 6 | } | 413 | | | 414 | 6 | return true; | 415 | 6 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIlEELb0ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIlEELb1ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIlEELb1ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 4 | CastParameters& params) { | 381 | 4 | MaxNativeType tmp; | 382 | 4 | if constexpr (multiply_may_overflow) { | 383 | 4 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 0 | if (params.is_strict) { | 385 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 0 | precision, scale); | 387 | 0 | } | 388 | 0 | return false; | 389 | 0 | } | 390 | 4 | if constexpr (narrow_integral) { | 391 | 4 | if (tmp < min_result || tmp > max_result) { | 392 | 2 | if (params.is_strict) { | 393 | 1 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 1 | from, int_type_name<FromCppT>, precision, scale); | 395 | 1 | } | 396 | 2 | return false; | 397 | 2 | } | 398 | 4 | } | 399 | 2 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 4 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIlEELb0ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIlEELb0ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIlEELb1ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIlEELb1ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIlEELb0ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIlEELb0ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIlEELb1ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIlEELb1ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIlEELb0ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIlEELb0ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 112 | CastParameters& params) { | 381 | 112 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 112 | } else { | 401 | 112 | tmp = scale_multiplier * from; | 402 | 112 | if constexpr (narrow_integral) { | 403 | 112 | if (tmp < min_result || tmp > max_result) { | 404 | 32 | if (params.is_strict) { | 405 | 16 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 16 | from, int_type_name<FromCppT>, precision, scale); | 407 | 16 | } | 408 | 32 | return false; | 409 | 32 | } | 410 | 112 | } | 411 | 80 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 112 | } | 413 | | | 414 | 0 | return true; | 415 | 112 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIlEELb1ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIlEELb1ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 56 | CastParameters& params) { | 381 | 56 | MaxNativeType tmp; | 382 | 56 | if constexpr (multiply_may_overflow) { | 383 | 56 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 52 | if constexpr (narrow_integral) { | 391 | 52 | if (tmp < min_result || tmp > max_result) { | 392 | 12 | if (params.is_strict) { | 393 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 6 | from, int_type_name<FromCppT>, precision, scale); | 395 | 6 | } | 396 | 12 | return false; | 397 | 12 | } | 398 | 52 | } | 399 | 40 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 56 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIlEELb0ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIlEELb0ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 90 | CastParameters& params) { | 381 | 90 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 90 | } else { | 401 | 90 | tmp = scale_multiplier * from; | 402 | 90 | if constexpr (narrow_integral) { | 403 | 90 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 90 | } | 411 | 66 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 90 | } | 413 | | | 414 | 0 | return true; | 415 | 90 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIlEELb1ELb0ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIlEELb1ELb1ElQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 112 | CastParameters& params) { | 381 | 112 | MaxNativeType tmp; | 382 | 112 | if constexpr (multiply_may_overflow) { | 383 | 112 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 16 | if (params.is_strict) { | 385 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 8 | precision, scale); | 387 | 8 | } | 388 | 16 | return false; | 389 | 16 | } | 390 | 96 | if constexpr (narrow_integral) { | 391 | 96 | if (tmp < min_result || tmp > max_result) { | 392 | 16 | if (params.is_strict) { | 393 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 8 | from, int_type_name<FromCppT>, precision, scale); | 395 | 8 | } | 396 | 16 | return false; | 397 | 16 | } | 398 | 96 | } | 399 | 80 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 112 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIlEELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIlEELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 90 | CastParameters& params) { | 381 | 90 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 90 | } else { | 401 | 90 | tmp = scale_multiplier * from; | 402 | 90 | if constexpr (narrow_integral) { | 403 | 90 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 90 | } | 411 | 66 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 90 | } | 413 | | | 414 | 0 | return true; | 415 | 90 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIlEELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIlEELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS4_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS5_hEEEbRKS5_RS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 380 | 112 | CastParameters& params) { | 381 | 112 | MaxNativeType tmp; | 382 | 112 | if constexpr (multiply_may_overflow) { | 383 | 112 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 16 | if (params.is_strict) { | 385 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 8 | precision, scale); | 387 | 8 | } | 388 | 16 | return false; | 389 | 16 | } | 390 | 96 | if constexpr (narrow_integral) { | 391 | 96 | if (tmp < min_result || tmp > max_result) { | 392 | 16 | if (params.is_strict) { | 393 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 8 | from, int_type_name<FromCppT>, precision, scale); | 395 | 8 | } | 396 | 16 | return false; | 397 | 16 | } | 398 | 96 | } | 399 | 80 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 112 | } |
_ZN5doris13CastToDecimal9_from_intIhNS_12Decimal128V3ELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 6 | CastParameters& params) { | 381 | 6 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 6 | } else { | 401 | 6 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 6 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 6 | } | 413 | | | 414 | 6 | return true; | 415 | 6 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_12Decimal128V3ELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_12Decimal128V3ELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIhNS_12Decimal128V3ELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 4 | CastParameters& params) { | 381 | 4 | MaxNativeType tmp; | 382 | 4 | if constexpr (multiply_may_overflow) { | 383 | 4 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 0 | if (params.is_strict) { | 385 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 0 | precision, scale); | 387 | 0 | } | 388 | 0 | return false; | 389 | 0 | } | 390 | 4 | if constexpr (narrow_integral) { | 391 | 4 | if (tmp < min_result || tmp > max_result) { | 392 | 2 | if (params.is_strict) { | 393 | 1 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 1 | from, int_type_name<FromCppT>, precision, scale); | 395 | 1 | } | 396 | 2 | return false; | 397 | 2 | } | 398 | 4 | } | 399 | 2 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 4 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_12Decimal128V3ELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_12Decimal128V3ELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_12Decimal128V3ELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIaNS_12Decimal128V3ELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_12Decimal128V3ELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_12Decimal128V3ELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_12Decimal128V3ELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIsNS_12Decimal128V3ELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIiNS_12Decimal128V3ELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIiNS_12Decimal128V3ELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_12Decimal128V3ELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIiNS_12Decimal128V3ELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIlNS_12Decimal128V3ELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 18 | CastParameters& params) { | 381 | 18 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 18 | } else { | 401 | 18 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 18 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 18 | } | 413 | | | 414 | 18 | return true; | 415 | 18 | } |
_ZN5doris13CastToDecimal9_from_intIlNS_12Decimal128V3ELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 78 | CastParameters& params) { | 381 | 78 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 78 | } else { | 401 | 78 | tmp = scale_multiplier * from; | 402 | 78 | if constexpr (narrow_integral) { | 403 | 78 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 78 | } | 411 | 54 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 78 | } | 413 | | | 414 | 0 | return true; | 415 | 78 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_12Decimal128V3ELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIlNS_12Decimal128V3ELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_12Decimal128V3ELb0ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_12Decimal128V3ELb0ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 90 | CastParameters& params) { | 381 | 90 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 90 | } else { | 401 | 90 | tmp = scale_multiplier * from; | 402 | 90 | if constexpr (narrow_integral) { | 403 | 90 | if (tmp < min_result || tmp > max_result) { | 404 | 24 | if (params.is_strict) { | 405 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 12 | from, int_type_name<FromCppT>, precision, scale); | 407 | 12 | } | 408 | 24 | return false; | 409 | 24 | } | 410 | 90 | } | 411 | 66 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 90 | } | 413 | | | 414 | 0 | return true; | 415 | 90 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_12Decimal128V3ELb1ELb0EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_12Decimal128V3ELb1ELb1EnQaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS3_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 380 | 112 | CastParameters& params) { | 381 | 112 | MaxNativeType tmp; | 382 | 112 | if constexpr (multiply_may_overflow) { | 383 | 112 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 16 | if (params.is_strict) { | 385 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 8 | precision, scale); | 387 | 8 | } | 388 | 16 | return false; | 389 | 16 | } | 390 | 96 | if constexpr (narrow_integral) { | 391 | 96 | if (tmp < min_result || tmp > max_result) { | 392 | 16 | if (params.is_strict) { | 393 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 8 | from, int_type_name<FromCppT>, precision, scale); | 395 | 8 | } | 396 | 16 | return false; | 397 | 16 | } | 398 | 96 | } | 399 | 80 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 112 | } |
_ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 6 | CastParameters& params) { | 381 | 6 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 6 | } else { | 401 | 6 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 6 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 6 | } | 413 | | | 414 | 6 | return true; | 415 | 6 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIhNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 4 | CastParameters& params) { | 381 | 4 | MaxNativeType tmp; | 382 | 4 | if constexpr (multiply_may_overflow) { | 383 | 4 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 0 | if (params.is_strict) { | 385 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 0 | precision, scale); | 387 | 0 | } | 388 | 0 | return false; | 389 | 0 | } | 390 | 4 | if constexpr (narrow_integral) { | 391 | 4 | if (tmp < min_result || tmp > max_result) { | 392 | 2 | if (params.is_strict) { | 393 | 1 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 1 | from, int_type_name<FromCppT>, precision, scale); | 395 | 1 | } | 396 | 2 | return false; | 397 | 2 | } | 398 | 4 | } | 399 | 2 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 4 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIaNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIsNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIiNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
_ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 36 | CastParameters& params) { | 381 | 36 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 36 | } else { | 401 | 36 | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | 36 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 36 | } | 413 | | | 414 | 36 | return true; | 415 | 36 | } |
_ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 44 | CastParameters& params) { | 381 | 44 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 44 | } else { | 401 | 44 | tmp = scale_multiplier * from; | 402 | 44 | if constexpr (narrow_integral) { | 403 | 44 | if (tmp < min_result || tmp > max_result) { | 404 | 16 | if (params.is_strict) { | 405 | 8 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 8 | from, int_type_name<FromCppT>, precision, scale); | 407 | 8 | } | 408 | 16 | return false; | 409 | 16 | } | 410 | 44 | } | 411 | 28 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 44 | } | 413 | | | 414 | 0 | return true; | 415 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intIlNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 22 | CastParameters& params) { | 381 | 22 | MaxNativeType tmp; | 382 | 22 | if constexpr (multiply_may_overflow) { | 383 | 22 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 18 | if constexpr (narrow_integral) { | 391 | 18 | if (tmp < min_result || tmp > max_result) { | 392 | 4 | if (params.is_strict) { | 393 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 2 | from, int_type_name<FromCppT>, precision, scale); | 395 | 2 | } | 396 | 4 | return false; | 397 | 4 | } | 398 | 18 | } | 399 | 14 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 22 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 112 | CastParameters& params) { | 381 | 112 | MaxNativeType tmp; | 382 | | if constexpr (multiply_may_overflow) { | 383 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | | if (params.is_strict) { | 385 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | | precision, scale); | 387 | | } | 388 | | return false; | 389 | | } | 390 | | if constexpr (narrow_integral) { | 391 | | if (tmp < min_result || tmp > max_result) { | 392 | | if (params.is_strict) { | 393 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | | from, int_type_name<FromCppT>, precision, scale); | 395 | | } | 396 | | return false; | 397 | | } | 398 | | } | 399 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | 112 | } else { | 401 | 112 | tmp = scale_multiplier * from; | 402 | 112 | if constexpr (narrow_integral) { | 403 | 112 | if (tmp < min_result || tmp > max_result) { | 404 | 32 | if (params.is_strict) { | 405 | 16 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | 16 | from, int_type_name<FromCppT>, precision, scale); | 407 | 16 | } | 408 | 32 | return false; | 409 | 32 | } | 410 | 112 | } | 411 | 80 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | 112 | } | 413 | | | 414 | 0 | return true; | 415 | 112 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal9_from_intInNS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES5_Qaaaa15IsDecimalNumberIT0_Ent14IsDecimal128V2IS7_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS8_hEEEbRKS8_RS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 380 | 56 | CastParameters& params) { | 381 | 56 | MaxNativeType tmp; | 382 | 56 | if constexpr (multiply_may_overflow) { | 383 | 56 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 384 | 4 | if (params.is_strict) { | 385 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 386 | 2 | precision, scale); | 387 | 2 | } | 388 | 4 | return false; | 389 | 4 | } | 390 | 52 | if constexpr (narrow_integral) { | 391 | 52 | if (tmp < min_result || tmp > max_result) { | 392 | 12 | if (params.is_strict) { | 393 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 394 | 6 | from, int_type_name<FromCppT>, precision, scale); | 395 | 6 | } | 396 | 12 | return false; | 397 | 12 | } | 398 | 52 | } | 399 | 40 | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 400 | | } else { | 401 | | tmp = scale_multiplier * from; | 402 | | if constexpr (narrow_integral) { | 403 | | if (tmp < min_result || tmp > max_result) { | 404 | | if (params.is_strict) { | 405 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 406 | | from, int_type_name<FromCppT>, precision, scale); | 407 | | } | 408 | | return false; | 409 | | } | 410 | | } | 411 | | to.value = static_cast<typename ToCppT::NativeType>(tmp); | 412 | | } | 413 | | | 414 | 0 | return true; | 415 | 56 | } |
|
416 | | |
417 | | template <typename FromCppT, typename ToCppT, bool multiply_may_overflow, bool narrow_integral, |
418 | | typename MaxNativeType = |
419 | | std::conditional_t<(sizeof(FromCppT) > sizeof(typename ToCppT::NativeType)), |
420 | | FromCppT, typename ToCppT::NativeType>> |
421 | | requires(IsDecimalV2<ToCppT> && (IsCppTypeInt<FromCppT> || std::is_same_v<FromCppT, UInt8>)) |
422 | | static inline bool _from_int(const FromCppT& from, ToCppT& to, UInt32 precision, UInt32 scale, |
423 | | const MaxNativeType& scale_multiplier, |
424 | | const typename ToCppT::NativeType& min_result, |
425 | | const typename ToCppT::NativeType& max_result, |
426 | 6 | CastParameters& params) { |
427 | 6 | MaxNativeType tmp; |
428 | 6 | if constexpr (multiply_may_overflow) { |
429 | 0 | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { |
430 | 0 | if (params.is_strict) { |
431 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, |
432 | 0 | precision, scale); |
433 | 0 | } |
434 | 0 | return false; |
435 | 0 | } |
436 | 0 | if constexpr (narrow_integral) { |
437 | 0 | if (tmp < min_result || tmp > max_result) { |
438 | 0 | if (params.is_strict) { |
439 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
440 | 0 | from, int_type_name<FromCppT>, precision, scale); |
441 | 0 | } |
442 | 0 | return false; |
443 | 0 | } |
444 | 0 | } |
445 | 0 | to = DecimalV2Value(static_cast<typename ToCppT::NativeType>(tmp)); |
446 | 6 | } else { |
447 | 6 | tmp = scale_multiplier * from; |
448 | 6 | if constexpr (narrow_integral) { |
449 | 4 | if (tmp < min_result || tmp > max_result) { |
450 | 2 | if (params.is_strict) { |
451 | 1 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
452 | 1 | from, int_type_name<FromCppT>, precision, scale); |
453 | 1 | } |
454 | 2 | return false; |
455 | 2 | } |
456 | 4 | } |
457 | 2 | to = DecimalV2Value(static_cast<typename ToCppT::NativeType>(tmp)); |
458 | 6 | } |
459 | | |
460 | 0 | return true; |
461 | 6 | } _ZN5doris13CastToDecimal9_from_intIhNS_14DecimalV2ValueELb0ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 426 | 2 | CastParameters& params) { | 427 | 2 | MaxNativeType tmp; | 428 | | if constexpr (multiply_may_overflow) { | 429 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 430 | | if (params.is_strict) { | 431 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 432 | | precision, scale); | 433 | | } | 434 | | return false; | 435 | | } | 436 | | if constexpr (narrow_integral) { | 437 | | if (tmp < min_result || tmp > max_result) { | 438 | | if (params.is_strict) { | 439 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 440 | | from, int_type_name<FromCppT>, precision, scale); | 441 | | } | 442 | | return false; | 443 | | } | 444 | | } | 445 | | to = DecimalV2Value(static_cast<typename ToCppT::NativeType>(tmp)); | 446 | 2 | } else { | 447 | 2 | tmp = scale_multiplier * from; | 448 | | if constexpr (narrow_integral) { | 449 | | if (tmp < min_result || tmp > max_result) { | 450 | | if (params.is_strict) { | 451 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 452 | | from, int_type_name<FromCppT>, precision, scale); | 453 | | } | 454 | | return false; | 455 | | } | 456 | | } | 457 | 2 | to = DecimalV2Value(static_cast<typename ToCppT::NativeType>(tmp)); | 458 | 2 | } | 459 | | | 460 | 2 | return true; | 461 | 2 | } |
_ZN5doris13CastToDecimal9_from_intIhNS_14DecimalV2ValueELb0ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 426 | 4 | CastParameters& params) { | 427 | 4 | MaxNativeType tmp; | 428 | | if constexpr (multiply_may_overflow) { | 429 | | if (common::mul_overflow(static_cast<MaxNativeType>(from), scale_multiplier, tmp)) { | 430 | | if (params.is_strict) { | 431 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR(from, int_type_name<FromCppT>, | 432 | | precision, scale); | 433 | | } | 434 | | return false; | 435 | | } | 436 | | if constexpr (narrow_integral) { | 437 | | if (tmp < min_result || tmp > max_result) { | 438 | | if (params.is_strict) { | 439 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 440 | | from, int_type_name<FromCppT>, precision, scale); | 441 | | } | 442 | | return false; | 443 | | } | 444 | | } | 445 | | to = DecimalV2Value(static_cast<typename ToCppT::NativeType>(tmp)); | 446 | 4 | } else { | 447 | 4 | tmp = scale_multiplier * from; | 448 | 4 | if constexpr (narrow_integral) { | 449 | 4 | if (tmp < min_result || tmp > max_result) { | 450 | 2 | if (params.is_strict) { | 451 | 1 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 452 | 1 | from, int_type_name<FromCppT>, precision, scale); | 453 | 1 | } | 454 | 2 | return false; | 455 | 2 | } | 456 | 4 | } | 457 | 2 | to = DecimalV2Value(static_cast<typename ToCppT::NativeType>(tmp)); | 458 | 4 | } | 459 | | | 460 | 0 | return true; | 461 | 4 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_14DecimalV2ValueELb1ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIhNS_14DecimalV2ValueELb1ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_14DecimalV2ValueELb0ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_14DecimalV2ValueELb0ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_14DecimalV2ValueELb1ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIaNS_14DecimalV2ValueELb1ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_14DecimalV2ValueELb0ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_14DecimalV2ValueELb0ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_14DecimalV2ValueELb1ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIsNS_14DecimalV2ValueELb1ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_14DecimalV2ValueELb0ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_14DecimalV2ValueELb0ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_14DecimalV2ValueELb1ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIiNS_14DecimalV2ValueELb1ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_14DecimalV2ValueELb0ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_14DecimalV2ValueELb0ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_14DecimalV2ValueELb1ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intIlNS_14DecimalV2ValueELb1ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_14DecimalV2ValueELb0ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_14DecimalV2ValueELb0ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_14DecimalV2ValueELb1ELb0EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal9_from_intInNS_14DecimalV2ValueELb1ELb1EnQaa11IsDecimalV2IT0_Eoo12IsCppTypeIntIT_Esr3stdE9is_same_vIS4_hEEEbRKS4_RS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE |
462 | | |
463 | | template < |
464 | | typename FromCppT, typename ToCppT, bool multiply_may_overflow, bool narrow_integral, |
465 | | typename MaxNativeType = std::conditional_t< |
466 | | (sizeof(FromCppT) == sizeof(ToCppT)) && |
467 | | (std::is_same_v<ToCppT, Decimal128V3> || |
468 | | std::is_same_v<FromCppT, Decimal128V3>), |
469 | | Decimal128V3::NativeType, |
470 | | std::conditional_t<(sizeof(FromCppT) > sizeof(ToCppT)), |
471 | | typename FromCppT::NativeType, typename ToCppT::NativeType>>> |
472 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
473 | | static inline bool _from_decimal_smaller_scale( |
474 | | const FromCppT& from, const UInt32 precision_from, const UInt32 scale_from, ToCppT& to, |
475 | | UInt32 precision_to, UInt32 scale_to, const MaxNativeType& scale_multiplier, |
476 | | const typename ToCppT::NativeType& min_result, |
477 | 4.60k | const typename ToCppT::NativeType& max_result, CastParameters& params) { |
478 | 4.60k | MaxNativeType res; |
479 | 4.60k | if constexpr (multiply_may_overflow) { |
480 | 2.65k | if constexpr (IsDecimal128V2<FromCppT>) { |
481 | 357 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, |
482 | 357 | res)) { |
483 | 28 | if (params.is_strict) { |
484 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
485 | 6 | decimal_to_string(from.value(), scale_from), |
486 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), |
487 | 6 | precision_to, scale_to); |
488 | 6 | } |
489 | 28 | return false; |
490 | 329 | } else { |
491 | 329 | if (UNLIKELY(res > max_result || res < -max_result)) { |
492 | 80 | if (params.is_strict) { |
493 | 48 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
494 | 48 | decimal_to_string(from.value(), scale_from), |
495 | 48 | fmt::format("decimal({}, {})", precision_from, scale_from), |
496 | 48 | precision_to, scale_to); |
497 | 48 | } |
498 | 80 | return false; |
499 | 249 | } else { |
500 | 249 | to = ToCppT(res); |
501 | 249 | } |
502 | 329 | } |
503 | 2.30k | } else { |
504 | 2.30k | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, |
505 | 2.30k | res)) { |
506 | 361 | if (params.is_strict) { |
507 | 30 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
508 | 30 | decimal_to_string(from.value, scale_from), |
509 | 30 | fmt::format("decimal({}, {})", precision_from, scale_from), |
510 | 30 | precision_to, scale_to); |
511 | 30 | } |
512 | 361 | return false; |
513 | 1.94k | } else { |
514 | 1.94k | if (UNLIKELY(res > max_result || res < -max_result)) { |
515 | 889 | if (params.is_strict) { |
516 | 594 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
517 | 594 | decimal_to_string(from.value, scale_from), |
518 | 594 | fmt::format("decimal({}, {})", precision_from, scale_from), |
519 | 594 | precision_to, scale_to); |
520 | 594 | } |
521 | 889 | return false; |
522 | 1.05k | } else { |
523 | 1.05k | to = ToCppT(res); |
524 | 1.05k | } |
525 | 1.94k | } |
526 | 2.30k | } |
527 | 2.65k | } else { |
528 | 1.94k | if constexpr (IsDecimal128V2<FromCppT>) { |
529 | 212 | res = from.value() * scale_multiplier; |
530 | 1.73k | } else { |
531 | 1.73k | res = from.value * scale_multiplier; |
532 | 1.73k | } |
533 | 1.94k | if constexpr (narrow_integral) { |
534 | 884 | if (UNLIKELY(res > max_result || res < -max_result)) { |
535 | 414 | if constexpr (IsDecimal128V2<FromCppT>) { |
536 | 60 | if (params.is_strict) { |
537 | 30 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
538 | 30 | decimal_to_string(from.value(), scale_from), |
539 | 30 | fmt::format("decimal({}, {})", precision_from, scale_from), |
540 | 30 | precision_to, scale_to); |
541 | 30 | } |
542 | 354 | } else { |
543 | 354 | if (params.is_strict) { |
544 | 177 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
545 | 177 | decimal_to_string(from.value, scale_from), |
546 | 177 | fmt::format("decimal({}, {})", precision_from, scale_from), |
547 | 177 | precision_to, scale_to); |
548 | 177 | } |
549 | 354 | } |
550 | 414 | return false; |
551 | 414 | } |
552 | 884 | } |
553 | 470 | to = ToCppT(res); |
554 | 1.94k | } |
555 | 1.30k | return true; |
556 | 4.60k | } _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEES3_Lb0ELb0EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 14 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 14 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 14 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 14 | } else { | 531 | 14 | res = from.value * scale_multiplier; | 532 | 14 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 14 | to = ToCppT(res); | 554 | 14 | } | 555 | 14 | return true; | 556 | 14 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEES3_Lb0ELb1EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 7 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 7 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 7 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 7 | } else { | 531 | 7 | res = from.value * scale_multiplier; | 532 | 7 | } | 533 | 7 | if constexpr (narrow_integral) { | 534 | 7 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 6 | } else { | 543 | 6 | if (params.is_strict) { | 544 | 3 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 3 | decimal_to_string(from.value, scale_from), | 546 | 3 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 3 | precision_to, scale_to); | 548 | 3 | } | 549 | 6 | } | 550 | 6 | return false; | 551 | 6 | } | 552 | 7 | } | 553 | 1 | to = ToCppT(res); | 554 | 7 | } | 555 | 0 | return true; | 556 | 7 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEES3_Lb1ELb0EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEES3_Lb1ELb1EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 84 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 84 | MaxNativeType res; | 479 | 84 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 84 | } else { | 504 | 84 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 84 | res)) { | 506 | 16 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 16 | return false; | 513 | 68 | } else { | 514 | 68 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 32 | if (params.is_strict) { | 516 | 24 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 24 | decimal_to_string(from.value, scale_from), | 518 | 24 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 24 | precision_to, scale_to); | 520 | 24 | } | 521 | 32 | return false; | 522 | 36 | } else { | 523 | 36 | to = ToCppT(res); | 524 | 36 | } | 525 | 68 | } | 526 | 84 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 36 | return true; | 556 | 84 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IiEELb0ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IiEELb0ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IiEELb1ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IiEELb1ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 126 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 126 | MaxNativeType res; | 479 | 126 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 126 | } else { | 504 | 126 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 126 | res)) { | 506 | 14 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 14 | return false; | 513 | 112 | } else { | 514 | 112 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 58 | if (params.is_strict) { | 516 | 36 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 36 | decimal_to_string(from.value, scale_from), | 518 | 36 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 36 | precision_to, scale_to); | 520 | 36 | } | 521 | 58 | return false; | 522 | 58 | } else { | 523 | 54 | to = ToCppT(res); | 524 | 54 | } | 525 | 112 | } | 526 | 126 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 54 | return true; | 556 | 126 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIiEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIiEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIiEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIiEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 126 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 126 | MaxNativeType res; | 479 | 126 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 126 | } else { | 504 | 126 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 126 | res)) { | 506 | 12 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 12 | return false; | 513 | 114 | } else { | 514 | 114 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 60 | if (params.is_strict) { | 516 | 36 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 36 | decimal_to_string(from.value, scale_from), | 518 | 36 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 36 | precision_to, scale_to); | 520 | 36 | } | 521 | 60 | return false; | 522 | 60 | } else { | 523 | 54 | to = ToCppT(res); | 524 | 54 | } | 525 | 114 | } | 526 | 126 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 54 | return true; | 556 | 126 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 126 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 126 | MaxNativeType res; | 479 | 126 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 126 | } else { | 504 | 126 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 126 | res)) { | 506 | 12 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 12 | return false; | 513 | 114 | } else { | 514 | 114 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 60 | if (params.is_strict) { | 516 | 36 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 36 | decimal_to_string(from.value, scale_from), | 518 | 36 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 36 | precision_to, scale_to); | 520 | 36 | } | 521 | 60 | return false; | 522 | 60 | } else { | 523 | 54 | to = ToCppT(res); | 524 | 54 | } | 525 | 114 | } | 526 | 126 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 54 | return true; | 556 | 126 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IlEELb0ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 112 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 112 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 112 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 112 | } else { | 531 | 112 | res = from.value * scale_multiplier; | 532 | 112 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 112 | to = ToCppT(res); | 554 | 112 | } | 555 | 112 | return true; | 556 | 112 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IlEELb0ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 58 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 58 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 58 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 58 | } else { | 531 | 58 | res = from.value * scale_multiplier; | 532 | 58 | } | 533 | 58 | if constexpr (narrow_integral) { | 534 | 58 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 30 | } else { | 543 | 30 | if (params.is_strict) { | 544 | 15 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 15 | decimal_to_string(from.value, scale_from), | 546 | 15 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 15 | precision_to, scale_to); | 548 | 15 | } | 549 | 30 | } | 550 | 30 | return false; | 551 | 30 | } | 552 | 58 | } | 553 | 28 | to = ToCppT(res); | 554 | 58 | } | 555 | 0 | return true; | 556 | 58 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IlEELb1ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IlEELb1ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 72 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 72 | MaxNativeType res; | 479 | 72 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 72 | } else { | 504 | 72 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 72 | res)) { | 506 | 11 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 11 | return false; | 513 | 61 | } else { | 514 | 61 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 31 | if (params.is_strict) { | 516 | 21 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 21 | decimal_to_string(from.value, scale_from), | 518 | 21 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 21 | precision_to, scale_to); | 520 | 21 | } | 521 | 31 | return false; | 522 | 31 | } else { | 523 | 30 | to = ToCppT(res); | 524 | 30 | } | 525 | 61 | } | 526 | 72 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 30 | return true; | 556 | 72 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEES3_Lb0ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 46 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 46 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 46 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 46 | } else { | 531 | 46 | res = from.value * scale_multiplier; | 532 | 46 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 46 | to = ToCppT(res); | 554 | 46 | } | 555 | 46 | return true; | 556 | 46 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEES3_Lb0ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 44 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 44 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 44 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 44 | } else { | 531 | 44 | res = from.value * scale_multiplier; | 532 | 44 | } | 533 | 44 | if constexpr (narrow_integral) { | 534 | 44 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 18 | } else { | 543 | 18 | if (params.is_strict) { | 544 | 9 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 9 | decimal_to_string(from.value, scale_from), | 546 | 9 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 9 | precision_to, scale_to); | 548 | 9 | } | 549 | 18 | } | 550 | 18 | return false; | 551 | 18 | } | 552 | 44 | } | 553 | 26 | to = ToCppT(res); | 554 | 44 | } | 555 | 0 | return true; | 556 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEES3_Lb1ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEES3_Lb1ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 210 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 210 | MaxNativeType res; | 479 | 210 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 210 | } else { | 504 | 210 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 210 | res)) { | 506 | 36 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 36 | return false; | 513 | 174 | } else { | 514 | 174 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 78 | if (params.is_strict) { | 516 | 57 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 57 | decimal_to_string(from.value, scale_from), | 518 | 57 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 57 | precision_to, scale_to); | 520 | 57 | } | 521 | 78 | return false; | 522 | 96 | } else { | 523 | 96 | to = ToCppT(res); | 524 | 96 | } | 525 | 174 | } | 526 | 210 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 96 | return true; | 556 | 210 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIlEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIlEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIlEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIlEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 224 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 224 | MaxNativeType res; | 479 | 224 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 224 | } else { | 504 | 224 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 224 | res)) { | 506 | 20 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 20 | return false; | 513 | 204 | } else { | 514 | 204 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 100 | if (params.is_strict) { | 516 | 60 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 60 | decimal_to_string(from.value, scale_from), | 518 | 60 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 60 | precision_to, scale_to); | 520 | 60 | } | 521 | 100 | return false; | 522 | 104 | } else { | 523 | 104 | to = ToCppT(res); | 524 | 104 | } | 525 | 204 | } | 526 | 224 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 104 | return true; | 556 | 224 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 224 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 224 | MaxNativeType res; | 479 | 224 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 224 | } else { | 504 | 224 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 224 | res)) { | 506 | 20 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 20 | return false; | 513 | 204 | } else { | 514 | 204 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 100 | if (params.is_strict) { | 516 | 60 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 60 | decimal_to_string(from.value, scale_from), | 518 | 60 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 60 | precision_to, scale_to); | 520 | 60 | } | 521 | 100 | return false; | 522 | 104 | } else { | 523 | 104 | to = ToCppT(res); | 524 | 104 | } | 525 | 204 | } | 526 | 224 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 104 | return true; | 556 | 224 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS_12Decimal128V3ELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 120 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 120 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 120 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 120 | } else { | 531 | 120 | res = from.value * scale_multiplier; | 532 | 120 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 120 | to = ToCppT(res); | 554 | 120 | } | 555 | 120 | return true; | 556 | 120 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS_12Decimal128V3ELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 65 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 65 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 65 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 65 | } else { | 531 | 65 | res = from.value * scale_multiplier; | 532 | 65 | } | 533 | 65 | if constexpr (narrow_integral) { | 534 | 65 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 36 | } else { | 543 | 36 | if (params.is_strict) { | 544 | 18 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 18 | decimal_to_string(from.value, scale_from), | 546 | 18 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 18 | precision_to, scale_to); | 548 | 18 | } | 549 | 36 | } | 550 | 36 | return false; | 551 | 36 | } | 552 | 65 | } | 553 | 29 | to = ToCppT(res); | 554 | 65 | } | 555 | 0 | return true; | 556 | 65 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS_12Decimal128V3ELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS_12Decimal128V3ELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 65 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 65 | MaxNativeType res; | 479 | 65 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 65 | } else { | 504 | 65 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 65 | res)) { | 506 | 20 | if (params.is_strict) { | 507 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 6 | decimal_to_string(from.value, scale_from), | 509 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 6 | precision_to, scale_to); | 511 | 6 | } | 512 | 20 | return false; | 513 | 45 | } else { | 514 | 45 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 16 | if (params.is_strict) { | 516 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 12 | decimal_to_string(from.value, scale_from), | 518 | 12 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 12 | precision_to, scale_to); | 520 | 12 | } | 521 | 16 | return false; | 522 | 29 | } else { | 523 | 29 | to = ToCppT(res); | 524 | 29 | } | 525 | 45 | } | 526 | 65 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 29 | return true; | 556 | 65 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS_12Decimal128V3ELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 176 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 176 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 176 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 176 | } else { | 531 | 176 | res = from.value * scale_multiplier; | 532 | 176 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 176 | to = ToCppT(res); | 554 | 176 | } | 555 | 176 | return true; | 556 | 176 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS_12Decimal128V3ELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 116 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 116 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 116 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 116 | } else { | 531 | 116 | res = from.value * scale_multiplier; | 532 | 116 | } | 533 | 116 | if constexpr (narrow_integral) { | 534 | 116 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 60 | } else { | 543 | 60 | if (params.is_strict) { | 544 | 30 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 30 | decimal_to_string(from.value, scale_from), | 546 | 30 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 30 | precision_to, scale_to); | 548 | 30 | } | 549 | 60 | } | 550 | 60 | return false; | 551 | 60 | } | 552 | 116 | } | 553 | 56 | to = ToCppT(res); | 554 | 116 | } | 555 | 0 | return true; | 556 | 116 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS_12Decimal128V3ELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS_12Decimal128V3ELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 116 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 116 | MaxNativeType res; | 479 | 116 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 116 | } else { | 504 | 116 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 116 | res)) { | 506 | 36 | if (params.is_strict) { | 507 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 12 | decimal_to_string(from.value, scale_from), | 509 | 12 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 12 | precision_to, scale_to); | 511 | 12 | } | 512 | 36 | return false; | 513 | 80 | } else { | 514 | 80 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 24 | if (params.is_strict) { | 516 | 18 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 18 | decimal_to_string(from.value, scale_from), | 518 | 18 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 18 | precision_to, scale_to); | 520 | 18 | } | 521 | 24 | return false; | 522 | 56 | } else { | 523 | 56 | to = ToCppT(res); | 524 | 56 | } | 525 | 80 | } | 526 | 116 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 56 | return true; | 556 | 116 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ES2_Lb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 477 | 46 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 46 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 46 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 46 | } else { | 531 | 46 | res = from.value * scale_multiplier; | 532 | 46 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 46 | to = ToCppT(res); | 554 | 46 | } | 555 | 46 | return true; | 556 | 46 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ES2_Lb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 477 | 70 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 70 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 70 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 70 | } else { | 531 | 70 | res = from.value * scale_multiplier; | 532 | 70 | } | 533 | 70 | if constexpr (narrow_integral) { | 534 | 70 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 36 | } else { | 543 | 36 | if (params.is_strict) { | 544 | 18 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 18 | decimal_to_string(from.value, scale_from), | 546 | 18 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 18 | precision_to, scale_to); | 548 | 18 | } | 549 | 36 | } | 550 | 36 | return false; | 551 | 36 | } | 552 | 70 | } | 553 | 34 | to = ToCppT(res); | 554 | 70 | } | 555 | 0 | return true; | 556 | 70 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ES2_Lb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ES2_Lb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 477 | 190 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 190 | MaxNativeType res; | 479 | 190 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 190 | } else { | 504 | 190 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 190 | res)) { | 506 | 50 | if (params.is_strict) { | 507 | 12 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 12 | decimal_to_string(from.value, scale_from), | 509 | 12 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 12 | precision_to, scale_to); | 511 | 12 | } | 512 | 50 | return false; | 513 | 140 | } else { | 514 | 140 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 48 | if (params.is_strict) { | 516 | 36 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 36 | decimal_to_string(from.value, scale_from), | 518 | 36 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 36 | precision_to, scale_to); | 520 | 36 | } | 521 | 48 | return false; | 522 | 92 | } else { | 523 | 92 | to = ToCppT(res); | 524 | 92 | } | 525 | 140 | } | 526 | 190 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 92 | return true; | 556 | 190 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 224 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 224 | MaxNativeType res; | 479 | 224 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 224 | } else { | 504 | 224 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 224 | res)) { | 506 | 22 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 22 | return false; | 513 | 202 | } else { | 514 | 202 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 98 | if (params.is_strict) { | 516 | 60 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 60 | decimal_to_string(from.value, scale_from), | 518 | 60 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 60 | precision_to, scale_to); | 520 | 60 | } | 521 | 98 | return false; | 522 | 104 | } else { | 523 | 104 | to = ToCppT(res); | 524 | 104 | } | 525 | 202 | } | 526 | 224 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 104 | return true; | 556 | 224 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 120 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 120 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 120 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 120 | } else { | 531 | 120 | res = from.value * scale_multiplier; | 532 | 120 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 120 | to = ToCppT(res); | 554 | 120 | } | 555 | 120 | return true; | 556 | 120 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 65 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 65 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 65 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 65 | } else { | 531 | 65 | res = from.value * scale_multiplier; | 532 | 65 | } | 533 | 65 | if constexpr (narrow_integral) { | 534 | 65 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 36 | } else { | 543 | 36 | if (params.is_strict) { | 544 | 18 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 18 | decimal_to_string(from.value, scale_from), | 546 | 18 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 18 | precision_to, scale_to); | 548 | 18 | } | 549 | 36 | } | 550 | 36 | return false; | 551 | 36 | } | 552 | 65 | } | 553 | 29 | to = ToCppT(res); | 554 | 65 | } | 555 | 0 | return true; | 556 | 65 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 65 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 65 | MaxNativeType res; | 479 | 65 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 65 | } else { | 504 | 65 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 65 | res)) { | 506 | 12 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 12 | return false; | 513 | 53 | } else { | 514 | 53 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 24 | if (params.is_strict) { | 516 | 18 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 18 | decimal_to_string(from.value, scale_from), | 518 | 18 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 18 | precision_to, scale_to); | 520 | 18 | } | 521 | 24 | return false; | 522 | 29 | } else { | 523 | 29 | to = ToCppT(res); | 524 | 29 | } | 525 | 53 | } | 526 | 65 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 29 | return true; | 556 | 65 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 184 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 184 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 184 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 184 | } else { | 531 | 184 | res = from.value * scale_multiplier; | 532 | 184 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 184 | to = ToCppT(res); | 554 | 184 | } | 555 | 184 | return true; | 556 | 184 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 116 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 116 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 116 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 116 | } else { | 531 | 116 | res = from.value * scale_multiplier; | 532 | 116 | } | 533 | 116 | if constexpr (narrow_integral) { | 534 | 116 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 60 | } else { | 543 | 60 | if (params.is_strict) { | 544 | 30 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 30 | decimal_to_string(from.value, scale_from), | 546 | 30 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 30 | precision_to, scale_to); | 548 | 30 | } | 549 | 60 | } | 550 | 60 | return false; | 551 | 60 | } | 552 | 116 | } | 553 | 56 | to = ToCppT(res); | 554 | 116 | } | 555 | 0 | return true; | 556 | 116 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 116 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 116 | MaxNativeType res; | 479 | 116 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 116 | } else { | 504 | 116 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 116 | res)) { | 506 | 20 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 20 | return false; | 513 | 96 | } else { | 514 | 96 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 40 | if (params.is_strict) { | 516 | 30 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 30 | decimal_to_string(from.value, scale_from), | 518 | 30 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 30 | precision_to, scale_to); | 520 | 30 | } | 521 | 40 | return false; | 522 | 56 | } else { | 523 | 56 | to = ToCppT(res); | 524 | 56 | } | 525 | 96 | } | 526 | 116 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 56 | return true; | 556 | 116 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 176 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 176 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 176 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 176 | } else { | 531 | 176 | res = from.value * scale_multiplier; | 532 | 176 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 176 | to = ToCppT(res); | 554 | 176 | } | 555 | 176 | return true; | 556 | 176 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 109 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 109 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 109 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 109 | } else { | 531 | 109 | res = from.value * scale_multiplier; | 532 | 109 | } | 533 | 109 | if constexpr (narrow_integral) { | 534 | 109 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 54 | } else { | 543 | 54 | if (params.is_strict) { | 544 | 27 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 27 | decimal_to_string(from.value, scale_from), | 546 | 27 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 27 | precision_to, scale_to); | 548 | 27 | } | 549 | 54 | } | 550 | 54 | return false; | 551 | 54 | } | 552 | 109 | } | 553 | 55 | to = ToCppT(res); | 554 | 109 | } | 555 | 0 | return true; | 556 | 109 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 123 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 123 | MaxNativeType res; | 479 | 123 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 123 | } else { | 504 | 123 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 123 | res)) { | 506 | 22 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 22 | return false; | 513 | 101 | } else { | 514 | 101 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 44 | if (params.is_strict) { | 516 | 33 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 33 | decimal_to_string(from.value, scale_from), | 518 | 33 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 33 | precision_to, scale_to); | 520 | 33 | } | 521 | 44 | return false; | 522 | 57 | } else { | 523 | 57 | to = ToCppT(res); | 524 | 57 | } | 525 | 101 | } | 526 | 123 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 57 | return true; | 556 | 123 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 477 | 46 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 46 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 46 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 46 | } else { | 531 | 46 | res = from.value * scale_multiplier; | 532 | 46 | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 46 | to = ToCppT(res); | 554 | 46 | } | 555 | 46 | return true; | 556 | 46 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 477 | 44 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 44 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 44 | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | 44 | } else { | 531 | 44 | res = from.value * scale_multiplier; | 532 | 44 | } | 533 | 44 | if constexpr (narrow_integral) { | 534 | 44 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | 18 | } else { | 543 | 18 | if (params.is_strict) { | 544 | 9 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | 9 | decimal_to_string(from.value, scale_from), | 546 | 9 | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | 9 | precision_to, scale_to); | 548 | 9 | } | 549 | 18 | } | 550 | 18 | return false; | 551 | 18 | } | 552 | 44 | } | 553 | 26 | to = ToCppT(res); | 554 | 44 | } | 555 | 0 | return true; | 556 | 44 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 477 | 210 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 210 | MaxNativeType res; | 479 | 210 | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | 210 | } else { | 504 | 210 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | 210 | res)) { | 506 | 38 | if (params.is_strict) { | 507 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | 0 | decimal_to_string(from.value, scale_from), | 509 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | 0 | precision_to, scale_to); | 511 | 0 | } | 512 | 38 | return false; | 513 | 172 | } else { | 514 | 172 | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | 76 | if (params.is_strict) { | 516 | 57 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | 57 | decimal_to_string(from.value, scale_from), | 518 | 57 | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | 57 | precision_to, scale_to); | 520 | 57 | } | 521 | 76 | return false; | 522 | 96 | } else { | 523 | 96 | to = ToCppT(res); | 524 | 96 | } | 525 | 172 | } | 526 | 210 | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 96 | return true; | 556 | 210 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 15 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 15 | MaxNativeType res; | 479 | 15 | if constexpr (multiply_may_overflow) { | 480 | 15 | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | 15 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | 15 | res)) { | 483 | 0 | if (params.is_strict) { | 484 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | 0 | decimal_to_string(from.value(), scale_from), | 486 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | 0 | precision_to, scale_to); | 488 | 0 | } | 489 | 0 | return false; | 490 | 15 | } else { | 491 | 15 | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | 0 | if (params.is_strict) { | 493 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | 0 | decimal_to_string(from.value(), scale_from), | 495 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | 0 | precision_to, scale_to); | 497 | 0 | } | 498 | 0 | return false; | 499 | 15 | } else { | 500 | 15 | to = ToCppT(res); | 501 | 15 | } | 502 | 15 | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 15 | return true; | 556 | 15 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 477 | 130 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 130 | MaxNativeType res; | 479 | 130 | if constexpr (multiply_may_overflow) { | 480 | 130 | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | 130 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | 130 | res)) { | 483 | 0 | if (params.is_strict) { | 484 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | 0 | decimal_to_string(from.value(), scale_from), | 486 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | 0 | precision_to, scale_to); | 488 | 0 | } | 489 | 0 | return false; | 490 | 130 | } else { | 491 | 130 | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | 48 | if (params.is_strict) { | 493 | 24 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | 24 | decimal_to_string(from.value(), scale_from), | 495 | 24 | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | 24 | precision_to, scale_to); | 497 | 24 | } | 498 | 48 | return false; | 499 | 82 | } else { | 500 | 82 | to = ToCppT(res); | 501 | 82 | } | 502 | 130 | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 82 | return true; | 556 | 130 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 11 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 11 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 11 | } else { | 528 | 11 | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | 11 | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 11 | to = ToCppT(res); | 554 | 11 | } | 555 | 11 | return true; | 556 | 11 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 95 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 95 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 95 | } else { | 528 | 95 | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | 95 | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | 95 | if constexpr (narrow_integral) { | 534 | 95 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | 30 | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | 30 | if (params.is_strict) { | 537 | 15 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | 15 | decimal_to_string(from.value(), scale_from), | 539 | 15 | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | 15 | precision_to, scale_to); | 541 | 15 | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | 30 | return false; | 551 | 30 | } | 552 | 95 | } | 553 | 65 | to = ToCppT(res); | 554 | 95 | } | 555 | 0 | return true; | 556 | 95 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 11 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 11 | MaxNativeType res; | 479 | 11 | if constexpr (multiply_may_overflow) { | 480 | 11 | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | 11 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | 11 | res)) { | 483 | 0 | if (params.is_strict) { | 484 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | 0 | decimal_to_string(from.value(), scale_from), | 486 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | 0 | precision_to, scale_to); | 488 | 0 | } | 489 | 0 | return false; | 490 | 11 | } else { | 491 | 11 | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | 0 | if (params.is_strict) { | 493 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | 0 | decimal_to_string(from.value(), scale_from), | 495 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | 0 | precision_to, scale_to); | 497 | 0 | } | 498 | 0 | return false; | 499 | 11 | } else { | 500 | 11 | to = ToCppT(res); | 501 | 11 | } | 502 | 11 | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 11 | return true; | 556 | 11 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 477 | 95 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 95 | MaxNativeType res; | 479 | 95 | if constexpr (multiply_may_overflow) { | 480 | 95 | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | 95 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | 95 | res)) { | 483 | 18 | if (params.is_strict) { | 484 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | 6 | decimal_to_string(from.value(), scale_from), | 486 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | 6 | precision_to, scale_to); | 488 | 6 | } | 489 | 18 | return false; | 490 | 77 | } else { | 491 | 77 | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | 12 | if (params.is_strict) { | 493 | 9 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | 9 | decimal_to_string(from.value(), scale_from), | 495 | 9 | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | 9 | precision_to, scale_to); | 497 | 9 | } | 498 | 12 | return false; | 499 | 65 | } else { | 500 | 65 | to = ToCppT(res); | 501 | 65 | } | 502 | 77 | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 65 | return true; | 556 | 95 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 11 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 11 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 11 | } else { | 528 | 11 | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | 11 | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | 11 | to = ToCppT(res); | 554 | 11 | } | 555 | 11 | return true; | 556 | 11 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 95 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 95 | MaxNativeType res; | 479 | | if constexpr (multiply_may_overflow) { | 480 | | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | | res)) { | 483 | | if (params.is_strict) { | 484 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | | decimal_to_string(from.value(), scale_from), | 486 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | | precision_to, scale_to); | 488 | | } | 489 | | return false; | 490 | | } else { | 491 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | | if (params.is_strict) { | 493 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | | decimal_to_string(from.value(), scale_from), | 495 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | | precision_to, scale_to); | 497 | | } | 498 | | return false; | 499 | | } else { | 500 | | to = ToCppT(res); | 501 | | } | 502 | | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | 95 | } else { | 528 | 95 | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | 95 | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | 95 | if constexpr (narrow_integral) { | 534 | 95 | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | 30 | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | 30 | if (params.is_strict) { | 537 | 15 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | 15 | decimal_to_string(from.value(), scale_from), | 539 | 15 | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | 15 | precision_to, scale_to); | 541 | 15 | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | 30 | return false; | 551 | 30 | } | 552 | 95 | } | 553 | 65 | to = ToCppT(res); | 554 | 95 | } | 555 | 0 | return true; | 556 | 95 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 11 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 11 | MaxNativeType res; | 479 | 11 | if constexpr (multiply_may_overflow) { | 480 | 11 | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | 11 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | 11 | res)) { | 483 | 0 | if (params.is_strict) { | 484 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | 0 | decimal_to_string(from.value(), scale_from), | 486 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | 0 | precision_to, scale_to); | 488 | 0 | } | 489 | 0 | return false; | 490 | 11 | } else { | 491 | 11 | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | 0 | if (params.is_strict) { | 493 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | 0 | decimal_to_string(from.value(), scale_from), | 495 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | 0 | precision_to, scale_to); | 497 | 0 | } | 498 | 0 | return false; | 499 | 11 | } else { | 500 | 11 | to = ToCppT(res); | 501 | 11 | } | 502 | 11 | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 11 | return true; | 556 | 11 | } |
_ZN5doris13CastToDecimal27_from_decimal_smaller_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 477 | 95 | const typename ToCppT::NativeType& max_result, CastParameters& params) { | 478 | 95 | MaxNativeType res; | 479 | 95 | if constexpr (multiply_may_overflow) { | 480 | 95 | if constexpr (IsDecimal128V2<FromCppT>) { | 481 | 95 | if (common::mul_overflow(static_cast<MaxNativeType>(from.value()), scale_multiplier, | 482 | 95 | res)) { | 483 | 10 | if (params.is_strict) { | 484 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 485 | 0 | decimal_to_string(from.value(), scale_from), | 486 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 487 | 0 | precision_to, scale_to); | 488 | 0 | } | 489 | 10 | return false; | 490 | 85 | } else { | 491 | 85 | if (UNLIKELY(res > max_result || res < -max_result)) { | 492 | 20 | if (params.is_strict) { | 493 | 15 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 494 | 15 | decimal_to_string(from.value(), scale_from), | 495 | 15 | fmt::format("decimal({}, {})", precision_from, scale_from), | 496 | 15 | precision_to, scale_to); | 497 | 15 | } | 498 | 20 | return false; | 499 | 65 | } else { | 500 | 65 | to = ToCppT(res); | 501 | 65 | } | 502 | 85 | } | 503 | | } else { | 504 | | if (common::mul_overflow(static_cast<MaxNativeType>(from.value), scale_multiplier, | 505 | | res)) { | 506 | | if (params.is_strict) { | 507 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 508 | | decimal_to_string(from.value, scale_from), | 509 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 510 | | precision_to, scale_to); | 511 | | } | 512 | | return false; | 513 | | } else { | 514 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 515 | | if (params.is_strict) { | 516 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 517 | | decimal_to_string(from.value, scale_from), | 518 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 519 | | precision_to, scale_to); | 520 | | } | 521 | | return false; | 522 | | } else { | 523 | | to = ToCppT(res); | 524 | | } | 525 | | } | 526 | | } | 527 | | } else { | 528 | | if constexpr (IsDecimal128V2<FromCppT>) { | 529 | | res = from.value() * scale_multiplier; | 530 | | } else { | 531 | | res = from.value * scale_multiplier; | 532 | | } | 533 | | if constexpr (narrow_integral) { | 534 | | if (UNLIKELY(res > max_result || res < -max_result)) { | 535 | | if constexpr (IsDecimal128V2<FromCppT>) { | 536 | | if (params.is_strict) { | 537 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 538 | | decimal_to_string(from.value(), scale_from), | 539 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 540 | | precision_to, scale_to); | 541 | | } | 542 | | } else { | 543 | | if (params.is_strict) { | 544 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 545 | | decimal_to_string(from.value, scale_from), | 546 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 547 | | precision_to, scale_to); | 548 | | } | 549 | | } | 550 | | return false; | 551 | | } | 552 | | } | 553 | | to = ToCppT(res); | 554 | | } | 555 | 65 | return true; | 556 | 95 | } |
|
557 | | |
558 | | template <typename FromCppT, typename ToCppT, typename ScaleT, bool narrow_integral> |
559 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
560 | | static inline bool _from_decimal_same_scale(const FromCppT& from, const UInt32 precision_from, |
561 | | const UInt32 scale_from, ToCppT& to, |
562 | | UInt32 precision_to, UInt32 scale_to, |
563 | | const typename ToCppT::NativeType& min_result, |
564 | | const typename ToCppT::NativeType& max_result, |
565 | 1.86k | CastParameters& params) { |
566 | 1.86k | if constexpr (IsDecimal128V2<FromCppT>) { |
567 | 106 | if constexpr (narrow_integral) { |
568 | 95 | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { |
569 | 30 | if (params.is_strict) { |
570 | 15 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
571 | 15 | decimal_to_string(from.value(), scale_from), |
572 | 15 | fmt::format("decimal({}, {})", precision_from, scale_from), |
573 | 15 | precision_to, scale_to); |
574 | 15 | } |
575 | 30 | return false; |
576 | 30 | } |
577 | 95 | } |
578 | 65 | to = ToCppT(from.value()); |
579 | 1.76k | } else { |
580 | 1.76k | if constexpr (narrow_integral) { |
581 | 1.05k | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { |
582 | 354 | if (params.is_strict) { |
583 | 177 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
584 | 177 | decimal_to_string(from.value, scale_from), |
585 | 177 | fmt::format("decimal({}, {})", precision_from, scale_from), |
586 | 177 | precision_to, scale_to); |
587 | 177 | } |
588 | 354 | return false; |
589 | 354 | } |
590 | 1.05k | } |
591 | 704 | to = ToCppT(from.value); |
592 | 1.76k | } |
593 | 0 | return true; |
594 | 1.86k | } _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEES3_iLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RNS_14CastParametersE Line | Count | Source | 565 | 8 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 8 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 8 | to = ToCppT(from.value); | 592 | 8 | } | 593 | 8 | return true; | 594 | 8 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEES3_iLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RNS_14CastParametersE Line | Count | Source | 565 | 19 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 19 | } else { | 580 | 19 | if constexpr (narrow_integral) { | 581 | 19 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 12 | if (params.is_strict) { | 583 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 6 | decimal_to_string(from.value, scale_from), | 585 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 6 | precision_to, scale_to); | 587 | 6 | } | 588 | 12 | return false; | 589 | 12 | } | 590 | 19 | } | 591 | 7 | to = ToCppT(from.value); | 592 | 19 | } | 593 | 0 | return true; | 594 | 19 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEENS2_IiEElLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEENS2_IiEElLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 136 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 136 | } else { | 580 | 136 | if constexpr (narrow_integral) { | 581 | 136 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 54 | if (params.is_strict) { | 583 | 27 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 27 | decimal_to_string(from.value, scale_from), | 585 | 27 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 27 | precision_to, scale_to); | 587 | 27 | } | 588 | 54 | return false; | 589 | 54 | } | 590 | 136 | } | 591 | 82 | to = ToCppT(from.value); | 592 | 136 | } | 593 | 0 | return true; | 594 | 136 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ENS_7DecimalIiEEnLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ENS_7DecimalIiEEnLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 122 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 122 | } else { | 580 | 122 | if constexpr (narrow_integral) { | 581 | 122 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 48 | if (params.is_strict) { | 583 | 24 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 24 | decimal_to_string(from.value, scale_from), | 585 | 24 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 24 | precision_to, scale_to); | 587 | 24 | } | 588 | 48 | return false; | 589 | 48 | } | 590 | 122 | } | 591 | 74 | to = ToCppT(from.value); | 592 | 122 | } | 593 | 0 | return true; | 594 | 122 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES5_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEES5_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 565 | 122 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 122 | } else { | 580 | 122 | if constexpr (narrow_integral) { | 581 | 122 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 48 | if (params.is_strict) { | 583 | 24 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 24 | decimal_to_string(from.value, scale_from), | 585 | 24 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 24 | precision_to, scale_to); | 587 | 24 | } | 588 | 48 | return false; | 589 | 48 | } | 590 | 122 | } | 591 | 74 | to = ToCppT(from.value); | 592 | 122 | } | 593 | 0 | return true; | 594 | 122 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEENS2_IlEElLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 82 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 82 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 82 | to = ToCppT(from.value); | 592 | 82 | } | 593 | 82 | return true; | 594 | 82 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEENS2_IlEElLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEES3_lLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RNS_14CastParametersE Line | Count | Source | 565 | 30 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 30 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 30 | to = ToCppT(from.value); | 592 | 30 | } | 593 | 30 | return true; | 594 | 30 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEES3_lLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RNS_14CastParametersE Line | Count | Source | 565 | 42 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 42 | } else { | 580 | 42 | if constexpr (narrow_integral) { | 581 | 42 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 12 | if (params.is_strict) { | 583 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 6 | decimal_to_string(from.value, scale_from), | 585 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 6 | precision_to, scale_to); | 587 | 6 | } | 588 | 12 | return false; | 589 | 12 | } | 590 | 42 | } | 591 | 30 | to = ToCppT(from.value); | 592 | 42 | } | 593 | 0 | return true; | 594 | 42 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ENS_7DecimalIlEEnLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ENS_7DecimalIlEEnLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 182 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 182 | } else { | 580 | 182 | if constexpr (narrow_integral) { | 581 | 182 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 54 | if (params.is_strict) { | 583 | 27 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 27 | decimal_to_string(from.value, scale_from), | 585 | 27 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 27 | precision_to, scale_to); | 587 | 27 | } | 588 | 54 | return false; | 589 | 54 | } | 590 | 182 | } | 591 | 128 | to = ToCppT(from.value); | 592 | 182 | } | 593 | 0 | return true; | 594 | 182 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES5_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEES5_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 565 | 168 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 168 | } else { | 580 | 168 | if constexpr (narrow_integral) { | 581 | 168 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 48 | if (params.is_strict) { | 583 | 24 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 24 | decimal_to_string(from.value, scale_from), | 585 | 24 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 24 | precision_to, scale_to); | 587 | 24 | } | 588 | 48 | return false; | 589 | 48 | } | 590 | 168 | } | 591 | 120 | to = ToCppT(from.value); | 592 | 168 | } | 593 | 0 | return true; | 594 | 168 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEENS_12Decimal128V3EnLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 74 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 74 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 74 | to = ToCppT(from.value); | 592 | 74 | } | 593 | 74 | return true; | 594 | 74 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEENS_12Decimal128V3EnLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEENS_12Decimal128V3EnLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 128 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 128 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 128 | to = ToCppT(from.value); | 592 | 128 | } | 593 | 128 | return true; | 594 | 128 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEENS_12Decimal128V3EnLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ES2_nLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKNS3_10NativeTypeESA_RNS_14CastParametersE Line | Count | Source | 565 | 31 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 31 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 31 | to = ToCppT(from.value); | 592 | 31 | } | 593 | 31 | return true; | 594 | 31 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ES2_nLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKNS3_10NativeTypeESA_RNS_14CastParametersE Line | Count | Source | 565 | 43 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 43 | } else { | 580 | 43 | if constexpr (narrow_integral) { | 581 | 43 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 12 | if (params.is_strict) { | 583 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 6 | decimal_to_string(from.value, scale_from), | 585 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 6 | precision_to, scale_to); | 587 | 6 | } | 588 | 12 | return false; | 589 | 12 | } | 590 | 43 | } | 591 | 31 | to = ToCppT(from.value); | 592 | 43 | } | 593 | 0 | return true; | 594 | 43 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES5_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ES5_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 565 | 182 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 182 | } else { | 580 | 182 | if constexpr (narrow_integral) { | 581 | 182 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 54 | if (params.is_strict) { | 583 | 27 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 27 | decimal_to_string(from.value, scale_from), | 585 | 27 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 27 | precision_to, scale_to); | 587 | 27 | } | 588 | 54 | return false; | 589 | 54 | } | 590 | 182 | } | 591 | 128 | to = ToCppT(from.value); | 592 | 182 | } | 593 | 0 | return true; | 594 | 182 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES6_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 565 | 74 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 74 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 74 | to = ToCppT(from.value); | 592 | 74 | } | 593 | 74 | return true; | 594 | 74 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEES6_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES6_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 565 | 120 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 120 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 120 | to = ToCppT(from.value); | 592 | 120 | } | 593 | 120 | return true; | 594 | 120 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEES6_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 565 | 128 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 128 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 128 | to = ToCppT(from.value); | 592 | 128 | } | 593 | 128 | return true; | 594 | 128 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_S5_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKNS7_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 565 | 30 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 30 | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | 30 | to = ToCppT(from.value); | 592 | 30 | } | 593 | 30 | return true; | 594 | 30 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_S5_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKNS7_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 565 | 42 | CastParameters& params) { | 566 | | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | | to = ToCppT(from.value()); | 579 | 42 | } else { | 580 | 42 | if constexpr (narrow_integral) { | 581 | 42 | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | 12 | if (params.is_strict) { | 583 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | 6 | decimal_to_string(from.value, scale_from), | 585 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | 6 | precision_to, scale_to); | 587 | 6 | } | 588 | 12 | return false; | 589 | 12 | } | 590 | 42 | } | 591 | 30 | to = ToCppT(from.value); | 592 | 42 | } | 593 | 0 | return true; | 594 | 42 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_7DecimalIiEEnLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 4 | CastParameters& params) { | 566 | 4 | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | 4 | to = ToCppT(from.value()); | 579 | | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | | to = ToCppT(from.value); | 592 | | } | 593 | 4 | return true; | 594 | 4 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_7DecimalIiEEnLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 35 | CastParameters& params) { | 566 | 35 | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | 35 | if constexpr (narrow_integral) { | 568 | 35 | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | 18 | if (params.is_strict) { | 570 | 9 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | 9 | decimal_to_string(from.value(), scale_from), | 572 | 9 | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | 9 | precision_to, scale_to); | 574 | 9 | } | 575 | 18 | return false; | 576 | 18 | } | 577 | 35 | } | 578 | 17 | to = ToCppT(from.value()); | 579 | | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | | to = ToCppT(from.value); | 592 | | } | 593 | 0 | return true; | 594 | 35 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_7DecimalIlEEnLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 7 | CastParameters& params) { | 566 | 7 | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | | if constexpr (narrow_integral) { | 568 | | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | | if (params.is_strict) { | 570 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | | decimal_to_string(from.value(), scale_from), | 572 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | | precision_to, scale_to); | 574 | | } | 575 | | return false; | 576 | | } | 577 | | } | 578 | 7 | to = ToCppT(from.value()); | 579 | | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | | to = ToCppT(from.value); | 592 | | } | 593 | 7 | return true; | 594 | 7 | } |
_ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_7DecimalIlEEnLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKNS5_10NativeTypeESC_RNS_14CastParametersE Line | Count | Source | 565 | 60 | CastParameters& params) { | 566 | 60 | if constexpr (IsDecimal128V2<FromCppT>) { | 567 | 60 | if constexpr (narrow_integral) { | 568 | 60 | if (UNLIKELY(from.value() > max_result || from.value() < -max_result)) { | 569 | 12 | if (params.is_strict) { | 570 | 6 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 571 | 6 | decimal_to_string(from.value(), scale_from), | 572 | 6 | fmt::format("decimal({}, {})", precision_from, scale_from), | 573 | 6 | precision_to, scale_to); | 574 | 6 | } | 575 | 12 | return false; | 576 | 12 | } | 577 | 60 | } | 578 | 48 | to = ToCppT(from.value()); | 579 | | } else { | 580 | | if constexpr (narrow_integral) { | 581 | | if (UNLIKELY(from.value > max_result || from.value < -max_result)) { | 582 | | if (params.is_strict) { | 583 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 584 | | decimal_to_string(from.value, scale_from), | 585 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 586 | | precision_to, scale_to); | 587 | | } | 588 | | return false; | 589 | | } | 590 | | } | 591 | | to = ToCppT(from.value); | 592 | | } | 593 | 0 | return true; | 594 | 60 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_12Decimal128V3EnLb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_12Decimal128V3EnLb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKNS4_10NativeTypeESB_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal24_from_decimal_same_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1EQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKNS8_10NativeTypeESF_RNS_14CastParametersE |
595 | | |
596 | | template < |
597 | | typename FromCppT, typename ToCppT, bool multiply_may_overflow, bool narrow_integral, |
598 | | typename MaxNativeType = std::conditional_t< |
599 | | (sizeof(FromCppT) == sizeof(ToCppT)) && |
600 | | (std::is_same_v<ToCppT, Decimal128V3> || |
601 | | std::is_same_v<FromCppT, Decimal128V3>), |
602 | | Decimal128V3::NativeType, |
603 | | std::conditional_t<(sizeof(FromCppT) > sizeof(ToCppT)), |
604 | | typename FromCppT::NativeType, typename ToCppT::NativeType>>> |
605 | | requires(IsDecimalNumber<ToCppT> && IsDecimalNumber<FromCppT>) |
606 | | static inline bool _from_decimal_bigger_scale(const FromCppT& from, const UInt32 precision_from, |
607 | | const UInt32 scale_from, ToCppT& to, |
608 | | UInt32 precision_to, UInt32 scale_to, |
609 | | const MaxNativeType& scale_multiplier, |
610 | | const typename ToCppT::NativeType& min_result, |
611 | | const typename ToCppT::NativeType& max_result, |
612 | 8.39k | CastParameters& params) { |
613 | 8.39k | MaxNativeType res; |
614 | 8.39k | if (from >= FromCppT(0)) { |
615 | 8.39k | if constexpr (narrow_integral) { |
616 | 3.34k | if constexpr (IsDecimal128V2<FromCppT>) { |
617 | 839 | res = (from.value() + scale_multiplier / 2) / scale_multiplier; |
618 | 839 | if (UNLIKELY(res > max_result)) { |
619 | 244 | if (params.is_strict) { |
620 | 122 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
621 | 122 | decimal_to_string(from.value(), scale_from), |
622 | 122 | fmt::format("decimal({}, {})", precision_from, scale_from), |
623 | 122 | precision_to, scale_to); |
624 | 122 | } |
625 | 244 | return false; |
626 | 244 | } |
627 | 2.50k | } else { |
628 | 2.50k | res = (from.value + scale_multiplier / 2) / scale_multiplier; |
629 | 2.50k | if (UNLIKELY(res > max_result)) { |
630 | 1.04k | if (params.is_strict) { |
631 | 522 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
632 | 522 | decimal_to_string(from.value, scale_from), |
633 | 522 | fmt::format("decimal({}, {})", precision_from, scale_from), |
634 | 522 | precision_to, scale_to); |
635 | 522 | } |
636 | 1.04k | return false; |
637 | 1.04k | } |
638 | 2.50k | } |
639 | 2.05k | to = ToCppT(res); |
640 | 5.05k | } else { |
641 | 5.05k | if constexpr (IsDecimal128V2<FromCppT>) { |
642 | 932 | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); |
643 | 4.12k | } else { |
644 | 4.12k | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); |
645 | 4.12k | } |
646 | 5.05k | } |
647 | 8.39k | } else { |
648 | 0 | if constexpr (narrow_integral) { |
649 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { |
650 | 0 | res = (from.value() - scale_multiplier / 2) / scale_multiplier; |
651 | 0 | if (UNLIKELY(res < -max_result)) { |
652 | 0 | if (params.is_strict) { |
653 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
654 | 0 | decimal_to_string(from.value(), scale_from), |
655 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), |
656 | 0 | precision_to, scale_to); |
657 | 0 | } |
658 | 0 | return false; |
659 | 0 | } |
660 | 0 | } else { |
661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; |
662 | 0 | if (UNLIKELY(res < -max_result)) { |
663 | 0 | if (params.is_strict) { |
664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( |
665 | 0 | decimal_to_string(from.value, scale_from), |
666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), |
667 | 0 | precision_to, scale_to); |
668 | 0 | } |
669 | 0 | return false; |
670 | 0 | } |
671 | 0 | } |
672 | 0 | to = ToCppT(res); |
673 | 0 | } else { |
674 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { |
675 | 0 | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); |
676 | 0 | } else { |
677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); |
678 | 0 | } |
679 | 0 | } |
680 | 0 | } |
681 | 0 | return true; |
682 | 8.39k | } _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEES3_Lb0ELb0EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 612 | 112 | CastParameters& params) { | 613 | 112 | MaxNativeType res; | 614 | 112 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 112 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 112 | } else { | 644 | 112 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 112 | } | 646 | 112 | } | 647 | 112 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 112 | return true; | 682 | 112 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEES3_Lb0ELb1EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 612 | 98 | CastParameters& params) { | 613 | 98 | MaxNativeType res; | 614 | 98 | if (from >= FromCppT(0)) { | 615 | 98 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 98 | } else { | 628 | 98 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 98 | if (UNLIKELY(res > max_result)) { | 630 | 46 | if (params.is_strict) { | 631 | 24 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 24 | decimal_to_string(from.value, scale_from), | 633 | 24 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 24 | precision_to, scale_to); | 635 | 24 | } | 636 | 46 | return false; | 637 | 46 | } | 638 | 98 | } | 639 | 52 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 98 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 98 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEES3_Lb1ELb0EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEES3_Lb1ELb1EiQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IiEELb0ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 160 | CastParameters& params) { | 613 | 160 | MaxNativeType res; | 614 | 160 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 160 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 160 | } else { | 644 | 160 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 160 | } | 646 | 160 | } | 647 | 160 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 160 | return true; | 682 | 160 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IiEELb0ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 323 | CastParameters& params) { | 613 | 323 | MaxNativeType res; | 614 | 323 | if (from >= FromCppT(0)) { | 615 | 323 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 323 | } else { | 628 | 323 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 323 | if (UNLIKELY(res > max_result)) { | 630 | 133 | if (params.is_strict) { | 631 | 66 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 66 | decimal_to_string(from.value, scale_from), | 633 | 66 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 66 | precision_to, scale_to); | 635 | 66 | } | 636 | 133 | return false; | 637 | 133 | } | 638 | 323 | } | 639 | 190 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 323 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 323 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IiEELb1ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IiEELb1ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIiEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 160 | CastParameters& params) { | 613 | 160 | MaxNativeType res; | 614 | 160 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 160 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 160 | } else { | 644 | 160 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 160 | } | 646 | 160 | } | 647 | 160 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 160 | return true; | 682 | 160 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIiEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 357 | CastParameters& params) { | 613 | 357 | MaxNativeType res; | 614 | 357 | if (from >= FromCppT(0)) { | 615 | 357 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 357 | } else { | 628 | 357 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 357 | if (UNLIKELY(res > max_result)) { | 630 | 161 | if (params.is_strict) { | 631 | 80 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 80 | decimal_to_string(from.value, scale_from), | 633 | 80 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 80 | precision_to, scale_to); | 635 | 80 | } | 636 | 161 | return false; | 637 | 161 | } | 638 | 357 | } | 639 | 196 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 357 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 357 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIiEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIiEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 160 | CastParameters& params) { | 613 | 160 | MaxNativeType res; | 614 | 160 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 160 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 160 | } else { | 644 | 160 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 160 | } | 646 | 160 | } | 647 | 160 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 160 | return true; | 682 | 160 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 357 | CastParameters& params) { | 613 | 357 | MaxNativeType res; | 614 | 357 | if (from >= FromCppT(0)) { | 615 | 357 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 357 | } else { | 628 | 357 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 357 | if (UNLIKELY(res > max_result)) { | 630 | 161 | if (params.is_strict) { | 631 | 80 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 80 | decimal_to_string(from.value, scale_from), | 633 | 80 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 80 | precision_to, scale_to); | 635 | 80 | } | 636 | 161 | return false; | 637 | 161 | } | 638 | 357 | } | 639 | 196 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 357 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 357 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IiEELb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IlEELb0ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 184 | CastParameters& params) { | 613 | 184 | MaxNativeType res; | 614 | 184 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 184 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 184 | } else { | 644 | 184 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 184 | } | 646 | 184 | } | 647 | 184 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 184 | return true; | 682 | 184 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IlEELb0ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IlEELb1ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IlEELb1ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEES3_Lb0ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 612 | 352 | CastParameters& params) { | 613 | 352 | MaxNativeType res; | 614 | 352 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 352 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 352 | } else { | 644 | 352 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 352 | } | 646 | 352 | } | 647 | 352 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 352 | return true; | 682 | 352 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEES3_Lb0ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 612 | 96 | CastParameters& params) { | 613 | 96 | MaxNativeType res; | 614 | 96 | if (from >= FromCppT(0)) { | 615 | 96 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 96 | } else { | 628 | 96 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 96 | if (UNLIKELY(res > max_result)) { | 630 | 40 | if (params.is_strict) { | 631 | 20 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 20 | decimal_to_string(from.value, scale_from), | 633 | 20 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 20 | precision_to, scale_to); | 635 | 20 | } | 636 | 40 | return false; | 637 | 40 | } | 638 | 96 | } | 639 | 56 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 96 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 96 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEES3_Lb1ELb0ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEES3_Lb1ELb1ElQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIlEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 288 | CastParameters& params) { | 613 | 288 | MaxNativeType res; | 614 | 288 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 288 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 288 | } else { | 644 | 288 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 288 | } | 646 | 288 | } | 647 | 288 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 288 | return true; | 682 | 288 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIlEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 350 | CastParameters& params) { | 613 | 350 | MaxNativeType res; | 614 | 350 | if (from >= FromCppT(0)) { | 615 | 350 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 350 | } else { | 628 | 350 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 350 | if (UNLIKELY(res > max_result)) { | 630 | 132 | if (params.is_strict) { | 631 | 66 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 66 | decimal_to_string(from.value, scale_from), | 633 | 66 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 66 | precision_to, scale_to); | 635 | 66 | } | 636 | 132 | return false; | 637 | 132 | } | 638 | 350 | } | 639 | 218 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 350 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 350 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIlEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIlEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 288 | CastParameters& params) { | 613 | 288 | MaxNativeType res; | 614 | 288 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 288 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 288 | } else { | 644 | 288 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 288 | } | 646 | 288 | } | 647 | 288 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 288 | return true; | 682 | 288 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 384 | CastParameters& params) { | 613 | 384 | MaxNativeType res; | 614 | 384 | if (from >= FromCppT(0)) { | 615 | 384 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 384 | } else { | 628 | 384 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 384 | if (UNLIKELY(res > max_result)) { | 630 | 160 | if (params.is_strict) { | 631 | 80 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 80 | decimal_to_string(from.value, scale_from), | 633 | 80 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 80 | precision_to, scale_to); | 635 | 80 | } | 636 | 160 | return false; | 637 | 160 | } | 638 | 384 | } | 639 | 224 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 384 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 384 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS2_IlEELb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS_12Decimal128V3ELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 184 | CastParameters& params) { | 613 | 184 | MaxNativeType res; | 614 | 184 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 184 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 184 | } else { | 644 | 184 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 184 | } | 646 | 184 | } | 647 | 184 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 184 | return true; | 682 | 184 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS_12Decimal128V3ELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS_12Decimal128V3ELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS_12Decimal128V3ELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS_12Decimal128V3ELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 352 | CastParameters& params) { | 613 | 352 | MaxNativeType res; | 614 | 352 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 352 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 352 | } else { | 644 | 352 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 352 | } | 646 | 352 | } | 647 | 352 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 352 | return true; | 682 | 352 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS_12Decimal128V3ELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS_12Decimal128V3ELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS_12Decimal128V3ELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ES2_Lb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 612 | 352 | CastParameters& params) { | 613 | 352 | MaxNativeType res; | 614 | 352 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 352 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 352 | } else { | 644 | 352 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 352 | } | 646 | 352 | } | 647 | 352 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 352 | return true; | 682 | 352 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ES2_Lb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Line | Count | Source | 612 | 96 | CastParameters& params) { | 613 | 96 | MaxNativeType res; | 614 | 96 | if (from >= FromCppT(0)) { | 615 | 96 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 96 | } else { | 628 | 96 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 96 | if (UNLIKELY(res > max_result)) { | 630 | 40 | if (params.is_strict) { | 631 | 20 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 20 | decimal_to_string(from.value, scale_from), | 633 | 20 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 20 | precision_to, scale_to); | 635 | 20 | } | 636 | 40 | return false; | 637 | 40 | } | 638 | 96 | } | 639 | 56 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 96 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 96 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ES2_Lb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ES2_Lb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS4_jjRS3_jjRKT3_RKNS3_10NativeTypeESD_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 288 | CastParameters& params) { | 613 | 288 | MaxNativeType res; | 614 | 288 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 288 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 288 | } else { | 644 | 288 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 288 | } | 646 | 288 | } | 647 | 288 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 288 | return true; | 682 | 288 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 350 | CastParameters& params) { | 613 | 350 | MaxNativeType res; | 614 | 350 | if (from >= FromCppT(0)) { | 615 | 350 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 350 | } else { | 628 | 350 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 350 | if (UNLIKELY(res > max_result)) { | 630 | 132 | if (params.is_strict) { | 631 | 66 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 66 | decimal_to_string(from.value, scale_from), | 633 | 66 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 66 | precision_to, scale_to); | 635 | 66 | } | 636 | 132 | return false; | 637 | 132 | } | 638 | 350 | } | 639 | 218 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 350 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 350 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEENS_12Decimal128V3ELb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 184 | CastParameters& params) { | 613 | 184 | MaxNativeType res; | 614 | 184 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 184 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 184 | } else { | 644 | 184 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 184 | } | 646 | 184 | } | 647 | 184 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 184 | return true; | 682 | 184 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIiEENS2_IN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 352 | CastParameters& params) { | 613 | 352 | MaxNativeType res; | 614 | 352 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 352 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 352 | } else { | 644 | 352 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 352 | } | 646 | 352 | } | 647 | 352 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 352 | return true; | 682 | 352 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIlEENS2_IN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 352 | CastParameters& params) { | 613 | 352 | MaxNativeType res; | 614 | 352 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 352 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 352 | } else { | 644 | 352 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 352 | } | 646 | 352 | } | 647 | 352 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 352 | return true; | 682 | 352 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_12Decimal128V3ENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 612 | 352 | CastParameters& params) { | 613 | 352 | MaxNativeType res; | 614 | 352 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 352 | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | 352 | } else { | 644 | 352 | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | 352 | } | 646 | 352 | } | 647 | 352 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | 0 | } else { | 677 | 0 | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | 0 | } | 679 | 0 | } | 680 | 0 | } | 681 | 352 | return true; | 682 | 352 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb0ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Line | Count | Source | 612 | 96 | CastParameters& params) { | 613 | 96 | MaxNativeType res; | 614 | 96 | if (from >= FromCppT(0)) { | 615 | 96 | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | 96 | } else { | 628 | 96 | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | 96 | if (UNLIKELY(res > max_result)) { | 630 | 40 | if (params.is_strict) { | 631 | 20 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | 20 | decimal_to_string(from.value, scale_from), | 633 | 20 | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | 20 | precision_to, scale_to); | 635 | 20 | } | 636 | 40 | return false; | 637 | 40 | } | 638 | 96 | } | 639 | 56 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 96 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | 0 | } else { | 661 | 0 | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | 0 | if (UNLIKELY(res < -max_result)) { | 663 | 0 | if (params.is_strict) { | 664 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | 0 | decimal_to_string(from.value, scale_from), | 666 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | 0 | precision_to, scale_to); | 668 | 0 | } | 669 | 0 | return false; | 670 | 0 | } | 671 | 0 | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 96 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1ELb0ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_7DecimalIN4wide7integerILm256EiEEEES6_Lb1ELb1ES5_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS8_jjRS7_jjRKT3_RKNS7_10NativeTypeESH_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 32 | CastParameters& params) { | 613 | 32 | MaxNativeType res; | 614 | 32 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 32 | } else { | 641 | 32 | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | 32 | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | 32 | } | 647 | 32 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | 0 | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | 0 | } | 680 | 0 | } | 681 | 32 | return true; | 682 | 32 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 435 | CastParameters& params) { | 613 | 435 | MaxNativeType res; | 614 | 435 | if (from >= FromCppT(0)) { | 615 | 435 | if constexpr (narrow_integral) { | 616 | 435 | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | 435 | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | 435 | if (UNLIKELY(res > max_result)) { | 619 | 156 | if (params.is_strict) { | 620 | 78 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | 78 | decimal_to_string(from.value(), scale_from), | 622 | 78 | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | 78 | precision_to, scale_to); | 624 | 78 | } | 625 | 156 | return false; | 626 | 156 | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | 279 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 435 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | 0 | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | 0 | if (UNLIKELY(res < -max_result)) { | 652 | 0 | if (params.is_strict) { | 653 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | 0 | decimal_to_string(from.value(), scale_from), | 655 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | 0 | precision_to, scale_to); | 657 | 0 | } | 658 | 0 | return false; | 659 | 0 | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 435 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIiEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 124 | CastParameters& params) { | 613 | 124 | MaxNativeType res; | 614 | 124 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 124 | } else { | 641 | 124 | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | 124 | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | 124 | } | 647 | 124 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | 0 | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | 0 | } | 680 | 0 | } | 681 | 124 | return true; | 682 | 124 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Line | Count | Source | 612 | 354 | CastParameters& params) { | 613 | 354 | MaxNativeType res; | 614 | 354 | if (from >= FromCppT(0)) { | 615 | 354 | if constexpr (narrow_integral) { | 616 | 354 | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | 354 | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | 354 | if (UNLIKELY(res > max_result)) { | 619 | 84 | if (params.is_strict) { | 620 | 42 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | 42 | decimal_to_string(from.value(), scale_from), | 622 | 42 | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | 42 | precision_to, scale_to); | 624 | 42 | } | 625 | 84 | return false; | 626 | 84 | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | 270 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 354 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | 0 | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | 0 | if (UNLIKELY(res < -max_result)) { | 652 | 0 | if (params.is_strict) { | 653 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | 0 | decimal_to_string(from.value(), scale_from), | 655 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | 0 | precision_to, scale_to); | 657 | 0 | } | 658 | 0 | return false; | 659 | 0 | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 354 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIlEELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS6_jjRS5_jjRKT3_RKNS5_10NativeTypeESF_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb0ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 612 | 364 | CastParameters& params) { | 613 | 364 | MaxNativeType res; | 614 | 364 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 364 | } else { | 641 | 364 | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | 364 | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | 364 | } | 647 | 364 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | 0 | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | 0 | } | 680 | 0 | } | 681 | 364 | return true; | 682 | 364 | } |
_ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb0ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Line | Count | Source | 612 | 50 | CastParameters& params) { | 613 | 50 | MaxNativeType res; | 614 | 50 | if (from >= FromCppT(0)) { | 615 | 50 | if constexpr (narrow_integral) { | 616 | 50 | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | 50 | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | 50 | if (UNLIKELY(res > max_result)) { | 619 | 4 | if (params.is_strict) { | 620 | 2 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | 2 | decimal_to_string(from.value(), scale_from), | 622 | 2 | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | 2 | precision_to, scale_to); | 624 | 2 | } | 625 | 4 | return false; | 626 | 4 | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | 46 | to = ToCppT(res); | 640 | | } else { | 641 | | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | | } | 647 | 50 | } else { | 648 | 0 | if constexpr (narrow_integral) { | 649 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | 0 | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | 0 | if (UNLIKELY(res < -max_result)) { | 652 | 0 | if (params.is_strict) { | 653 | 0 | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | 0 | decimal_to_string(from.value(), scale_from), | 655 | 0 | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | 0 | precision_to, scale_to); | 657 | 0 | } | 658 | 0 | return false; | 659 | 0 | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | 0 | to = ToCppT(res); | 673 | | } else { | 674 | | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | | } | 680 | 0 | } | 681 | 0 | return true; | 682 | 50 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb1ELb0EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_12Decimal128V3ELb1ELb1EnQaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS5_jjRS4_jjRKT3_RKNS4_10NativeTypeESE_RNS_14CastParametersE _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Line | Count | Source | 612 | 412 | CastParameters& params) { | 613 | 412 | MaxNativeType res; | 614 | 412 | if (from >= FromCppT(0)) { | 615 | | if constexpr (narrow_integral) { | 616 | | if constexpr (IsDecimal128V2<FromCppT>) { | 617 | | res = (from.value() + scale_multiplier / 2) / scale_multiplier; | 618 | | if (UNLIKELY(res > max_result)) { | 619 | | if (params.is_strict) { | 620 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 621 | | decimal_to_string(from.value(), scale_from), | 622 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 623 | | precision_to, scale_to); | 624 | | } | 625 | | return false; | 626 | | } | 627 | | } else { | 628 | | res = (from.value + scale_multiplier / 2) / scale_multiplier; | 629 | | if (UNLIKELY(res > max_result)) { | 630 | | if (params.is_strict) { | 631 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 632 | | decimal_to_string(from.value, scale_from), | 633 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 634 | | precision_to, scale_to); | 635 | | } | 636 | | return false; | 637 | | } | 638 | | } | 639 | | to = ToCppT(res); | 640 | 412 | } else { | 641 | 412 | if constexpr (IsDecimal128V2<FromCppT>) { | 642 | 412 | to = ToCppT((from.value() + scale_multiplier / 2) / scale_multiplier); | 643 | | } else { | 644 | | to = ToCppT((from.value + scale_multiplier / 2) / scale_multiplier); | 645 | | } | 646 | 412 | } | 647 | 412 | } else { | 648 | | if constexpr (narrow_integral) { | 649 | | if constexpr (IsDecimal128V2<FromCppT>) { | 650 | | res = (from.value() - scale_multiplier / 2) / scale_multiplier; | 651 | | if (UNLIKELY(res < -max_result)) { | 652 | | if (params.is_strict) { | 653 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 654 | | decimal_to_string(from.value(), scale_from), | 655 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 656 | | precision_to, scale_to); | 657 | | } | 658 | | return false; | 659 | | } | 660 | | } else { | 661 | | res = (from.value - scale_multiplier / 2) / scale_multiplier; | 662 | | if (UNLIKELY(res < -max_result)) { | 663 | | if (params.is_strict) { | 664 | | params.status = DECIMAL_CONVERT_OVERFLOW_ERROR( | 665 | | decimal_to_string(from.value, scale_from), | 666 | | fmt::format("decimal({}, {})", precision_from, scale_from), | 667 | | precision_to, scale_to); | 668 | | } | 669 | | return false; | 670 | | } | 671 | | } | 672 | | to = ToCppT(res); | 673 | 0 | } else { | 674 | 0 | if constexpr (IsDecimal128V2<FromCppT>) { | 675 | 0 | to = ToCppT((from.value() - scale_multiplier / 2) / scale_multiplier); | 676 | | } else { | 677 | | to = ToCppT((from.value - scale_multiplier / 2) / scale_multiplier); | 678 | | } | 679 | 0 | } | 680 | 0 | } | 681 | 412 | return true; | 682 | 412 | } |
Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb0ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb0ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE Unexecuted instantiation: _ZN5doris13CastToDecimal26_from_decimal_bigger_scaleINS_14DecimalV2ValueENS_7DecimalIN4wide7integerILm256EiEEEELb1ELb1ES6_Qaa15IsDecimalNumberIT0_E15IsDecimalNumberIT_EEEbRKS9_jjRS8_jjRKT3_RKNS8_10NativeTypeESI_RNS_14CastParametersE |
683 | | }; |
684 | | |
685 | | // Casting from string to decimal types. |
686 | | template <CastModeType Mode, typename ToDataType> |
687 | | requires(IsDataTypeDecimal<ToDataType>) |
688 | | class CastToImpl<Mode, DataTypeString, ToDataType> : public CastToBase { |
689 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
690 | | uint32_t result, size_t /*input_rows_count*/, |
691 | 5.86k | const NullMap::value_type* null_map = nullptr) const override { |
692 | 5.86k | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( |
693 | 5.86k | block.get_by_position(arguments[0]).column.get()); |
694 | | |
695 | 5.86k | auto to_type = block.get_by_position(result).type; |
696 | 5.86k | auto nested_to_type = remove_nullable(to_type); |
697 | 5.86k | auto serde = nested_to_type->get_serde(); |
698 | | |
699 | 5.86k | if constexpr (Mode == CastModeType::NonStrictMode) { |
700 | 2.89k | auto nullable_col_to = create_empty_nullable_column(nested_to_type); |
701 | | // may write nulls to nullable_col_to |
702 | 2.89k | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); |
703 | 2.89k | block.get_by_position(result).column = std::move(nullable_col_to); |
704 | 2.96k | } else if constexpr (Mode == CastModeType::StrictMode) { |
705 | 2.96k | MutableColumnPtr column_to = nested_to_type->create_column(); |
706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows |
707 | 2.96k | RETURN_IF_ERROR( |
708 | 2.96k | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); |
709 | 2.55k | block.get_by_position(result).column = std::move(column_to); |
710 | | } else { |
711 | | return Status::InternalError("Unsupported cast mode"); |
712 | | } |
713 | | |
714 | 0 | return Status::OK(); |
715 | 5.86k | } Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 854 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 854 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 854 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 854 | auto to_type = block.get_by_position(result).type; | 696 | 854 | auto nested_to_type = remove_nullable(to_type); | 697 | 854 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | 854 | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | 854 | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | 854 | RETURN_IF_ERROR( | 708 | 854 | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | 665 | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 854 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 782 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 782 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 782 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 782 | auto to_type = block.get_by_position(result).type; | 696 | 782 | auto nested_to_type = remove_nullable(to_type); | 697 | 782 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | 782 | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | 782 | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | 782 | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | 782 | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | | RETURN_IF_ERROR( | 708 | | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 782 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 709 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 709 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 709 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 709 | auto to_type = block.get_by_position(result).type; | 696 | 709 | auto nested_to_type = remove_nullable(to_type); | 697 | 709 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | 709 | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | 709 | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | 709 | RETURN_IF_ERROR( | 708 | 709 | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | 631 | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 709 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 709 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 709 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 709 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 709 | auto to_type = block.get_by_position(result).type; | 696 | 709 | auto nested_to_type = remove_nullable(to_type); | 697 | 709 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | 709 | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | 709 | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | 709 | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | 709 | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | | RETURN_IF_ERROR( | 708 | | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 709 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 709 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 709 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 709 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 709 | auto to_type = block.get_by_position(result).type; | 696 | 709 | auto nested_to_type = remove_nullable(to_type); | 697 | 709 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | 709 | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | 709 | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | 709 | RETURN_IF_ERROR( | 708 | 709 | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | 631 | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 709 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 710 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 710 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 710 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 710 | auto to_type = block.get_by_position(result).type; | 696 | 710 | auto nested_to_type = remove_nullable(to_type); | 697 | 710 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | 710 | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | 710 | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | 710 | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | 710 | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | | RETURN_IF_ERROR( | 708 | | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 710 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 695 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 695 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 695 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 695 | auto to_type = block.get_by_position(result).type; | 696 | 695 | auto nested_to_type = remove_nullable(to_type); | 697 | 695 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | 695 | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | 695 | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | 695 | RETURN_IF_ERROR( | 708 | 695 | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | 631 | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 695 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 691 | 696 | const NullMap::value_type* null_map = nullptr) const override { | 692 | 696 | const auto* col_from = assert_cast<const DataTypeString::ColumnType*>( | 693 | 696 | block.get_by_position(arguments[0]).column.get()); | 694 | | | 695 | 696 | auto to_type = block.get_by_position(result).type; | 696 | 696 | auto nested_to_type = remove_nullable(to_type); | 697 | 696 | auto serde = nested_to_type->get_serde(); | 698 | | | 699 | 696 | if constexpr (Mode == CastModeType::NonStrictMode) { | 700 | 696 | auto nullable_col_to = create_empty_nullable_column(nested_to_type); | 701 | | // may write nulls to nullable_col_to | 702 | 696 | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 703 | 696 | block.get_by_position(result).column = std::move(nullable_col_to); | 704 | | } else if constexpr (Mode == CastModeType::StrictMode) { | 705 | | MutableColumnPtr column_to = nested_to_type->create_column(); | 706 | | // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows | 707 | | RETURN_IF_ERROR( | 708 | | serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map)); | 709 | | block.get_by_position(result).column = std::move(column_to); | 710 | | } else { | 711 | | return Status::InternalError("Unsupported cast mode"); | 712 | | } | 713 | | | 714 | 0 | return Status::OK(); | 715 | 696 | } |
|
716 | | }; |
717 | | |
718 | | // cast bool and int to decimal. when may overflow, result column is nullable. |
719 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
720 | | requires(IsDataTypeDecimal<ToDataType> && |
721 | | (IsDataTypeInt<FromDataType> || IsDataTypeBool<FromDataType>)) |
722 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
723 | | public: |
724 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
725 | | uint32_t result, size_t input_rows_count, |
726 | 782 | const NullMap::value_type* null_map = nullptr) const override { |
727 | 782 | using FromFieldType = typename FromDataType::FieldType; |
728 | 782 | using ToFieldType = typename ToDataType::FieldType; |
729 | 782 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); |
730 | 782 | const auto* col_from = |
731 | 782 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); |
732 | 782 | if (!col_from) { |
733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", |
734 | 0 | named_from.column->get_name()); |
735 | 0 | } |
736 | | |
737 | 782 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); |
738 | 782 | constexpr UInt32 from_scale = 0; |
739 | | |
740 | 782 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); |
741 | 782 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); |
742 | 782 | UInt32 to_precision = to_decimal_type.get_precision(); |
743 | 782 | ToDataType::check_type_precision(to_precision); |
744 | 782 | UInt32 to_scale = to_decimal_type.get_scale(); |
745 | 782 | ToDataType::check_type_scale(to_scale); |
746 | | |
747 | 782 | auto from_max_int_digit_count = from_precision - from_scale; |
748 | 782 | auto to_max_int_digit_count = to_precision - to_scale; |
749 | | // may overflow. nullable result column. |
750 | 782 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); |
751 | | // only in non-strict mode and may overflow, we set nullable |
752 | 782 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; |
753 | | |
754 | 782 | constexpr UInt32 to_max_digits = |
755 | 782 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); |
756 | 782 | bool multiply_may_overflow = false; |
757 | 782 | if (to_scale > from_scale) { |
758 | 483 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; |
759 | 483 | } |
760 | 782 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > |
761 | 782 | sizeof(typename ToFieldType::NativeType)), |
762 | 782 | FromFieldType, typename ToFieldType::NativeType>; |
763 | 782 | MaxNativeType scale_multiplier = |
764 | 782 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); |
765 | 782 | typename ToFieldType::NativeType max_result = |
766 | 782 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); |
767 | 782 | typename ToFieldType::NativeType min_result = -max_result; |
768 | | |
769 | 782 | ColumnUInt8::MutablePtr col_null_map_to; |
770 | 782 | NullMap::value_type* null_map_data = nullptr; |
771 | 782 | if (narrow_integral) { |
772 | 673 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); |
773 | 673 | null_map_data = col_null_map_to->get_data().data(); |
774 | 673 | } |
775 | | |
776 | 782 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); |
777 | 782 | const auto& vec_from = col_from->get_data(); |
778 | 782 | const auto* vec_from_data = vec_from.data(); |
779 | 782 | auto& vec_to = col_to->get_data(); |
780 | 782 | auto* vec_to_data = vec_to.data(); |
781 | | |
782 | 782 | CastParameters params; |
783 | 782 | params.is_strict = (CastMode == CastModeType::StrictMode); |
784 | 782 | size_t size = vec_from.size(); |
785 | | |
786 | 782 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { |
787 | 778 | if (to_scale == 0 && !narrow_integral) { |
788 | 512 | for (size_t i = 0; i < size; i++) { |
789 | 458 | vec_to_data[i].value = |
790 | 458 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); |
791 | 458 | } |
792 | 54 | block.get_by_position(result).column = std::move(col_to); |
793 | 54 | return Status::OK(); |
794 | 54 | } |
795 | 778 | } |
796 | | |
797 | 782 | RETURN_IF_ERROR(std::visit( |
798 | 782 | [&](auto multiply_may_overflow, auto narrow_integral) { |
799 | 782 | for (size_t i = 0; i < size; i++) { |
800 | 782 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, |
801 | 782 | typename ToDataType::FieldType, |
802 | 782 | multiply_may_overflow, narrow_integral>( |
803 | 782 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, |
804 | 782 | scale_multiplier, min_result, max_result, params)) { |
805 | 782 | if (set_nullable) { |
806 | 782 | null_map_data[i] = 1; |
807 | 782 | } else { |
808 | 782 | return params.status; |
809 | 782 | } |
810 | 782 | } |
811 | 782 | } |
812 | 782 | return Status::OK(); |
813 | 782 | }, |
814 | 782 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); |
815 | | |
816 | 401 | if (narrow_integral) { |
817 | 292 | block.get_by_position(result).column = |
818 | 292 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); |
819 | 292 | } else { |
820 | 109 | block.get_by_position(result).column = std::move(col_to); |
821 | 109 | } |
822 | 401 | return Status::OK(); |
823 | 782 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 2 | using FromFieldType = typename FromDataType::FieldType; | 728 | 2 | using ToFieldType = typename ToDataType::FieldType; | 729 | 2 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 2 | const auto* col_from = | 731 | 2 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 2 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 2 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 2 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 2 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 2 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 2 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 2 | ToDataType::check_type_precision(to_precision); | 744 | 2 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 2 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 2 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 2 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 2 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 2 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 2 | constexpr UInt32 to_max_digits = | 755 | 2 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 2 | bool multiply_may_overflow = false; | 757 | 2 | if (to_scale > from_scale) { | 758 | 2 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 2 | } | 760 | 2 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 2 | sizeof(typename ToFieldType::NativeType)), | 762 | 2 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 2 | MaxNativeType scale_multiplier = | 764 | 2 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 2 | typename ToFieldType::NativeType max_result = | 766 | 2 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 2 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 2 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 2 | NullMap::value_type* null_map_data = nullptr; | 771 | 2 | if (narrow_integral) { | 772 | 2 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 2 | null_map_data = col_null_map_to->get_data().data(); | 774 | 2 | } | 775 | | | 776 | 2 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 2 | const auto& vec_from = col_from->get_data(); | 778 | 2 | const auto* vec_from_data = vec_from.data(); | 779 | 2 | auto& vec_to = col_to->get_data(); | 780 | 2 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 2 | CastParameters params; | 783 | 2 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 2 | size_t size = vec_from.size(); | 785 | | | 786 | | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | | if (to_scale == 0 && !narrow_integral) { | 788 | | for (size_t i = 0; i < size; i++) { | 789 | | vec_to_data[i].value = | 790 | | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | | } | 792 | | block.get_by_position(result).column = std::move(col_to); | 793 | | return Status::OK(); | 794 | | } | 795 | | } | 796 | | | 797 | 2 | RETURN_IF_ERROR(std::visit( | 798 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 2 | for (size_t i = 0; i < size; i++) { | 800 | 2 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 2 | typename ToDataType::FieldType, | 802 | 2 | multiply_may_overflow, narrow_integral>( | 803 | 2 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 2 | scale_multiplier, min_result, max_result, params)) { | 805 | 2 | if (set_nullable) { | 806 | 2 | null_map_data[i] = 1; | 807 | 2 | } else { | 808 | 2 | return params.status; | 809 | 2 | } | 810 | 2 | } | 811 | 2 | } | 812 | 2 | return Status::OK(); | 813 | 2 | }, | 814 | 2 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 1 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 1 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 1 | return Status::OK(); | 823 | 2 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 2 | using FromFieldType = typename FromDataType::FieldType; | 728 | 2 | using ToFieldType = typename ToDataType::FieldType; | 729 | 2 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 2 | const auto* col_from = | 731 | 2 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 2 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 2 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 2 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 2 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 2 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 2 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 2 | ToDataType::check_type_precision(to_precision); | 744 | 2 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 2 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 2 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 2 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 2 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 2 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 2 | constexpr UInt32 to_max_digits = | 755 | 2 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 2 | bool multiply_may_overflow = false; | 757 | 2 | if (to_scale > from_scale) { | 758 | 2 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 2 | } | 760 | 2 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 2 | sizeof(typename ToFieldType::NativeType)), | 762 | 2 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 2 | MaxNativeType scale_multiplier = | 764 | 2 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 2 | typename ToFieldType::NativeType max_result = | 766 | 2 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 2 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 2 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 2 | NullMap::value_type* null_map_data = nullptr; | 771 | 2 | if (narrow_integral) { | 772 | 1 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 1 | null_map_data = col_null_map_to->get_data().data(); | 774 | 1 | } | 775 | | | 776 | 2 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 2 | const auto& vec_from = col_from->get_data(); | 778 | 2 | const auto* vec_from_data = vec_from.data(); | 779 | 2 | auto& vec_to = col_to->get_data(); | 780 | 2 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 2 | CastParameters params; | 783 | 2 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 2 | size_t size = vec_from.size(); | 785 | | | 786 | | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | | if (to_scale == 0 && !narrow_integral) { | 788 | | for (size_t i = 0; i < size; i++) { | 789 | | vec_to_data[i].value = | 790 | | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | | } | 792 | | block.get_by_position(result).column = std::move(col_to); | 793 | | return Status::OK(); | 794 | | } | 795 | | } | 796 | | | 797 | 2 | RETURN_IF_ERROR(std::visit( | 798 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 2 | for (size_t i = 0; i < size; i++) { | 800 | 2 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 2 | typename ToDataType::FieldType, | 802 | 2 | multiply_may_overflow, narrow_integral>( | 803 | 2 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 2 | scale_multiplier, min_result, max_result, params)) { | 805 | 2 | if (set_nullable) { | 806 | 2 | null_map_data[i] = 1; | 807 | 2 | } else { | 808 | 2 | return params.status; | 809 | 2 | } | 810 | 2 | } | 811 | 2 | } | 812 | 2 | return Status::OK(); | 813 | 2 | }, | 814 | 2 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 2 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 1 | } else { | 820 | 1 | block.get_by_position(result).column = std::move(col_to); | 821 | 1 | } | 822 | 2 | return Status::OK(); | 823 | 2 | } |
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 2 | using FromFieldType = typename FromDataType::FieldType; | 728 | 2 | using ToFieldType = typename ToDataType::FieldType; | 729 | 2 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 2 | const auto* col_from = | 731 | 2 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 2 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 2 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 2 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 2 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 2 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 2 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 2 | ToDataType::check_type_precision(to_precision); | 744 | 2 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 2 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 2 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 2 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 2 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 2 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 2 | constexpr UInt32 to_max_digits = | 755 | 2 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 2 | bool multiply_may_overflow = false; | 757 | 2 | if (to_scale > from_scale) { | 758 | 2 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 2 | } | 760 | 2 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 2 | sizeof(typename ToFieldType::NativeType)), | 762 | 2 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 2 | MaxNativeType scale_multiplier = | 764 | 2 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 2 | typename ToFieldType::NativeType max_result = | 766 | 2 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 2 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 2 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 2 | NullMap::value_type* null_map_data = nullptr; | 771 | 2 | if (narrow_integral) { | 772 | 2 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 2 | null_map_data = col_null_map_to->get_data().data(); | 774 | 2 | } | 775 | | | 776 | 2 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 2 | const auto& vec_from = col_from->get_data(); | 778 | 2 | const auto* vec_from_data = vec_from.data(); | 779 | 2 | auto& vec_to = col_to->get_data(); | 780 | 2 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 2 | CastParameters params; | 783 | 2 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 2 | size_t size = vec_from.size(); | 785 | | | 786 | 2 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 2 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 2 | } | 796 | | | 797 | 2 | RETURN_IF_ERROR(std::visit( | 798 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 2 | for (size_t i = 0; i < size; i++) { | 800 | 2 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 2 | typename ToDataType::FieldType, | 802 | 2 | multiply_may_overflow, narrow_integral>( | 803 | 2 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 2 | scale_multiplier, min_result, max_result, params)) { | 805 | 2 | if (set_nullable) { | 806 | 2 | null_map_data[i] = 1; | 807 | 2 | } else { | 808 | 2 | return params.status; | 809 | 2 | } | 810 | 2 | } | 811 | 2 | } | 812 | 2 | return Status::OK(); | 813 | 2 | }, | 814 | 2 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 1 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 1 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 1 | return Status::OK(); | 823 | 2 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 5 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 5 | using FromFieldType = typename FromDataType::FieldType; | 728 | 5 | using ToFieldType = typename ToDataType::FieldType; | 729 | 5 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 5 | const auto* col_from = | 731 | 5 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 5 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 5 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 5 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 5 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 5 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 5 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 5 | ToDataType::check_type_precision(to_precision); | 744 | 5 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 5 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 5 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 5 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 5 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 5 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 5 | constexpr UInt32 to_max_digits = | 755 | 5 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 5 | bool multiply_may_overflow = false; | 757 | 5 | if (to_scale > from_scale) { | 758 | 4 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 4 | } | 760 | 5 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 5 | sizeof(typename ToFieldType::NativeType)), | 762 | 5 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 5 | MaxNativeType scale_multiplier = | 764 | 5 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 5 | typename ToFieldType::NativeType max_result = | 766 | 5 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 5 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 5 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 5 | NullMap::value_type* null_map_data = nullptr; | 771 | 5 | if (narrow_integral) { | 772 | 1 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 1 | null_map_data = col_null_map_to->get_data().data(); | 774 | 1 | } | 775 | | | 776 | 5 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 5 | const auto& vec_from = col_from->get_data(); | 778 | 5 | const auto* vec_from_data = vec_from.data(); | 779 | 5 | auto& vec_to = col_to->get_data(); | 780 | 5 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 5 | CastParameters params; | 783 | 5 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 5 | size_t size = vec_from.size(); | 785 | | | 786 | 5 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 5 | if (to_scale == 0 && !narrow_integral) { | 788 | 3 | for (size_t i = 0; i < size; i++) { | 789 | 2 | vec_to_data[i].value = | 790 | 2 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 2 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 5 | } | 796 | | | 797 | 5 | RETURN_IF_ERROR(std::visit( | 798 | 5 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 5 | for (size_t i = 0; i < size; i++) { | 800 | 5 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 5 | typename ToDataType::FieldType, | 802 | 5 | multiply_may_overflow, narrow_integral>( | 803 | 5 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 5 | scale_multiplier, min_result, max_result, params)) { | 805 | 5 | if (set_nullable) { | 806 | 5 | null_map_data[i] = 1; | 807 | 5 | } else { | 808 | 5 | return params.status; | 809 | 5 | } | 810 | 5 | } | 811 | 5 | } | 812 | 5 | return Status::OK(); | 813 | 5 | }, | 814 | 5 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 5 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 5 | return Status::OK(); | 823 | 5 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 23 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 23 | using FromFieldType = typename FromDataType::FieldType; | 728 | 23 | using ToFieldType = typename ToDataType::FieldType; | 729 | 23 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 23 | const auto* col_from = | 731 | 23 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 23 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 23 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 23 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 23 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 23 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 23 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 23 | ToDataType::check_type_precision(to_precision); | 744 | 23 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 23 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 23 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 23 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 23 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 23 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 23 | constexpr UInt32 to_max_digits = | 755 | 23 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 23 | bool multiply_may_overflow = false; | 757 | 23 | if (to_scale > from_scale) { | 758 | 16 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 16 | } | 760 | 23 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 23 | sizeof(typename ToFieldType::NativeType)), | 762 | 23 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 23 | MaxNativeType scale_multiplier = | 764 | 23 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 23 | typename ToFieldType::NativeType max_result = | 766 | 23 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 23 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 23 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 23 | NullMap::value_type* null_map_data = nullptr; | 771 | 23 | if (narrow_integral) { | 772 | 20 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 20 | null_map_data = col_null_map_to->get_data().data(); | 774 | 20 | } | 775 | | | 776 | 23 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 23 | const auto& vec_from = col_from->get_data(); | 778 | 23 | const auto* vec_from_data = vec_from.data(); | 779 | 23 | auto& vec_to = col_to->get_data(); | 780 | 23 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 23 | CastParameters params; | 783 | 23 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 23 | size_t size = vec_from.size(); | 785 | | | 786 | 23 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 23 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 23 | } | 796 | | | 797 | 23 | RETURN_IF_ERROR(std::visit( | 798 | 23 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 23 | for (size_t i = 0; i < size; i++) { | 800 | 23 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 23 | typename ToDataType::FieldType, | 802 | 23 | multiply_may_overflow, narrow_integral>( | 803 | 23 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 23 | scale_multiplier, min_result, max_result, params)) { | 805 | 23 | if (set_nullable) { | 806 | 23 | null_map_data[i] = 1; | 807 | 23 | } else { | 808 | 23 | return params.status; | 809 | 23 | } | 810 | 23 | } | 811 | 23 | } | 812 | 23 | return Status::OK(); | 813 | 23 | }, | 814 | 23 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 4 | block.get_by_position(result).column = | 818 | 4 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 3 | block.get_by_position(result).column = std::move(col_to); | 821 | 3 | } | 822 | 7 | return Status::OK(); | 823 | 23 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 11 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 11 | using FromFieldType = typename FromDataType::FieldType; | 728 | 11 | using ToFieldType = typename ToDataType::FieldType; | 729 | 11 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 11 | const auto* col_from = | 731 | 11 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 11 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 11 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 11 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 11 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 11 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 11 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 11 | ToDataType::check_type_precision(to_precision); | 744 | 11 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 11 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 11 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 11 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 11 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 11 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 11 | constexpr UInt32 to_max_digits = | 755 | 11 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 11 | bool multiply_may_overflow = false; | 757 | 11 | if (to_scale > from_scale) { | 758 | 7 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 7 | } | 760 | 11 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 11 | sizeof(typename ToFieldType::NativeType)), | 762 | 11 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 11 | MaxNativeType scale_multiplier = | 764 | 11 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 11 | typename ToFieldType::NativeType max_result = | 766 | 11 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 11 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 11 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 11 | NullMap::value_type* null_map_data = nullptr; | 771 | 11 | if (narrow_integral) { | 772 | 8 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 8 | null_map_data = col_null_map_to->get_data().data(); | 774 | 8 | } | 775 | | | 776 | 11 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 11 | const auto& vec_from = col_from->get_data(); | 778 | 11 | const auto* vec_from_data = vec_from.data(); | 779 | 11 | auto& vec_to = col_to->get_data(); | 780 | 11 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 11 | CastParameters params; | 783 | 11 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 11 | size_t size = vec_from.size(); | 785 | | | 786 | 11 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 11 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 11 | } | 796 | | | 797 | 11 | RETURN_IF_ERROR(std::visit( | 798 | 11 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 11 | for (size_t i = 0; i < size; i++) { | 800 | 11 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 11 | typename ToDataType::FieldType, | 802 | 11 | multiply_may_overflow, narrow_integral>( | 803 | 11 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 11 | scale_multiplier, min_result, max_result, params)) { | 805 | 11 | if (set_nullable) { | 806 | 11 | null_map_data[i] = 1; | 807 | 11 | } else { | 808 | 11 | return params.status; | 809 | 11 | } | 810 | 11 | } | 811 | 11 | } | 812 | 11 | return Status::OK(); | 813 | 11 | }, | 814 | 11 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 11 | if (narrow_integral) { | 817 | 8 | block.get_by_position(result).column = | 818 | 8 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 8 | } else { | 820 | 3 | block.get_by_position(result).column = std::move(col_to); | 821 | 3 | } | 822 | 11 | return Status::OK(); | 823 | 11 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 27 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 27 | using FromFieldType = typename FromDataType::FieldType; | 728 | 27 | using ToFieldType = typename ToDataType::FieldType; | 729 | 27 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 27 | const auto* col_from = | 731 | 27 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 27 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 27 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 27 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 27 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 27 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 27 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 27 | ToDataType::check_type_precision(to_precision); | 744 | 27 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 27 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 27 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 27 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 27 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 27 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 27 | constexpr UInt32 to_max_digits = | 755 | 27 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 27 | bool multiply_may_overflow = false; | 757 | 27 | if (to_scale > from_scale) { | 758 | 16 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 16 | } | 760 | 27 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 27 | sizeof(typename ToFieldType::NativeType)), | 762 | 27 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 27 | MaxNativeType scale_multiplier = | 764 | 27 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 27 | typename ToFieldType::NativeType max_result = | 766 | 27 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 27 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 27 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 27 | NullMap::value_type* null_map_data = nullptr; | 771 | 27 | if (narrow_integral) { | 772 | 25 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 25 | null_map_data = col_null_map_to->get_data().data(); | 774 | 25 | } | 775 | | | 776 | 27 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 27 | const auto& vec_from = col_from->get_data(); | 778 | 27 | const auto* vec_from_data = vec_from.data(); | 779 | 27 | auto& vec_to = col_to->get_data(); | 780 | 27 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 27 | CastParameters params; | 783 | 27 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 27 | size_t size = vec_from.size(); | 785 | | | 786 | 27 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 27 | if (to_scale == 0 && !narrow_integral) { | 788 | 10 | for (size_t i = 0; i < size; i++) { | 789 | 9 | vec_to_data[i].value = | 790 | 9 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 9 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 27 | } | 796 | | | 797 | 27 | RETURN_IF_ERROR(std::visit( | 798 | 27 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 27 | for (size_t i = 0; i < size; i++) { | 800 | 27 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 27 | typename ToDataType::FieldType, | 802 | 27 | multiply_may_overflow, narrow_integral>( | 803 | 27 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 27 | scale_multiplier, min_result, max_result, params)) { | 805 | 27 | if (set_nullable) { | 806 | 27 | null_map_data[i] = 1; | 807 | 27 | } else { | 808 | 27 | return params.status; | 809 | 27 | } | 810 | 27 | } | 811 | 27 | } | 812 | 27 | return Status::OK(); | 813 | 27 | }, | 814 | 27 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 5 | block.get_by_position(result).column = | 818 | 5 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 5 | } else { | 820 | 2 | block.get_by_position(result).column = std::move(col_to); | 821 | 2 | } | 822 | 7 | return Status::OK(); | 823 | 27 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 12 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 12 | using FromFieldType = typename FromDataType::FieldType; | 728 | 12 | using ToFieldType = typename ToDataType::FieldType; | 729 | 12 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 12 | const auto* col_from = | 731 | 12 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 12 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 12 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 12 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 12 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 12 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 12 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 12 | ToDataType::check_type_precision(to_precision); | 744 | 12 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 12 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 12 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 12 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 12 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 12 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 12 | constexpr UInt32 to_max_digits = | 755 | 12 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 12 | bool multiply_may_overflow = false; | 757 | 12 | if (to_scale > from_scale) { | 758 | 7 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 7 | } | 760 | 12 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 12 | sizeof(typename ToFieldType::NativeType)), | 762 | 12 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 12 | MaxNativeType scale_multiplier = | 764 | 12 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 12 | typename ToFieldType::NativeType max_result = | 766 | 12 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 12 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 12 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 12 | NullMap::value_type* null_map_data = nullptr; | 771 | 12 | if (narrow_integral) { | 772 | 10 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 10 | null_map_data = col_null_map_to->get_data().data(); | 774 | 10 | } | 775 | | | 776 | 12 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 12 | const auto& vec_from = col_from->get_data(); | 778 | 12 | const auto* vec_from_data = vec_from.data(); | 779 | 12 | auto& vec_to = col_to->get_data(); | 780 | 12 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 12 | CastParameters params; | 783 | 12 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 12 | size_t size = vec_from.size(); | 785 | | | 786 | 12 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 12 | if (to_scale == 0 && !narrow_integral) { | 788 | 10 | for (size_t i = 0; i < size; i++) { | 789 | 9 | vec_to_data[i].value = | 790 | 9 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 9 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 12 | } | 796 | | | 797 | 12 | RETURN_IF_ERROR(std::visit( | 798 | 12 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 12 | for (size_t i = 0; i < size; i++) { | 800 | 12 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 12 | typename ToDataType::FieldType, | 802 | 12 | multiply_may_overflow, narrow_integral>( | 803 | 12 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 12 | scale_multiplier, min_result, max_result, params)) { | 805 | 12 | if (set_nullable) { | 806 | 12 | null_map_data[i] = 1; | 807 | 12 | } else { | 808 | 12 | return params.status; | 809 | 12 | } | 810 | 12 | } | 811 | 12 | } | 812 | 12 | return Status::OK(); | 813 | 12 | }, | 814 | 12 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 12 | if (narrow_integral) { | 817 | 10 | block.get_by_position(result).column = | 818 | 10 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 10 | } else { | 820 | 2 | block.get_by_position(result).column = std::move(col_to); | 821 | 2 | } | 822 | 12 | return Status::OK(); | 823 | 12 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 35 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 35 | using FromFieldType = typename FromDataType::FieldType; | 728 | 35 | using ToFieldType = typename ToDataType::FieldType; | 729 | 35 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 35 | const auto* col_from = | 731 | 35 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 35 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 35 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 35 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 35 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 35 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 35 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 35 | ToDataType::check_type_precision(to_precision); | 744 | 35 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 35 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 35 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 35 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 35 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 35 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 35 | constexpr UInt32 to_max_digits = | 755 | 35 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 35 | bool multiply_may_overflow = false; | 757 | 35 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 35 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 35 | sizeof(typename ToFieldType::NativeType)), | 762 | 35 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 35 | MaxNativeType scale_multiplier = | 764 | 35 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 35 | typename ToFieldType::NativeType max_result = | 766 | 35 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 35 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 35 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 35 | NullMap::value_type* null_map_data = nullptr; | 771 | 35 | if (narrow_integral) { | 772 | 35 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 35 | null_map_data = col_null_map_to->get_data().data(); | 774 | 35 | } | 775 | | | 776 | 35 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 35 | const auto& vec_from = col_from->get_data(); | 778 | 35 | const auto* vec_from_data = vec_from.data(); | 779 | 35 | auto& vec_to = col_to->get_data(); | 780 | 35 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 35 | CastParameters params; | 783 | 35 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 35 | size_t size = vec_from.size(); | 785 | | | 786 | 35 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 35 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 35 | } | 796 | | | 797 | 35 | RETURN_IF_ERROR(std::visit( | 798 | 35 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 35 | for (size_t i = 0; i < size; i++) { | 800 | 35 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 35 | typename ToDataType::FieldType, | 802 | 35 | multiply_may_overflow, narrow_integral>( | 803 | 35 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 35 | scale_multiplier, min_result, max_result, params)) { | 805 | 35 | if (set_nullable) { | 806 | 35 | null_map_data[i] = 1; | 807 | 35 | } else { | 808 | 35 | return params.status; | 809 | 35 | } | 810 | 35 | } | 811 | 35 | } | 812 | 35 | return Status::OK(); | 813 | 35 | }, | 814 | 35 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 7 | block.get_by_position(result).column = | 818 | 7 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 7 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 7 | return Status::OK(); | 823 | 35 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 14 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 14 | using FromFieldType = typename FromDataType::FieldType; | 728 | 14 | using ToFieldType = typename ToDataType::FieldType; | 729 | 14 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 14 | const auto* col_from = | 731 | 14 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 14 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 14 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 14 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 14 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 14 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 14 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 14 | ToDataType::check_type_precision(to_precision); | 744 | 14 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 14 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 14 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 14 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 14 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 14 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 14 | constexpr UInt32 to_max_digits = | 755 | 14 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 14 | bool multiply_may_overflow = false; | 757 | 14 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 14 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 14 | sizeof(typename ToFieldType::NativeType)), | 762 | 14 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 14 | MaxNativeType scale_multiplier = | 764 | 14 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 14 | typename ToFieldType::NativeType max_result = | 766 | 14 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 14 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 14 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 14 | NullMap::value_type* null_map_data = nullptr; | 771 | 14 | if (narrow_integral) { | 772 | 14 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 14 | null_map_data = col_null_map_to->get_data().data(); | 774 | 14 | } | 775 | | | 776 | 14 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 14 | const auto& vec_from = col_from->get_data(); | 778 | 14 | const auto* vec_from_data = vec_from.data(); | 779 | 14 | auto& vec_to = col_to->get_data(); | 780 | 14 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 14 | CastParameters params; | 783 | 14 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 14 | size_t size = vec_from.size(); | 785 | | | 786 | 14 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 14 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 14 | } | 796 | | | 797 | 14 | RETURN_IF_ERROR(std::visit( | 798 | 14 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 14 | for (size_t i = 0; i < size; i++) { | 800 | 14 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 14 | typename ToDataType::FieldType, | 802 | 14 | multiply_may_overflow, narrow_integral>( | 803 | 14 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 14 | scale_multiplier, min_result, max_result, params)) { | 805 | 14 | if (set_nullable) { | 806 | 14 | null_map_data[i] = 1; | 807 | 14 | } else { | 808 | 14 | return params.status; | 809 | 14 | } | 810 | 14 | } | 811 | 14 | } | 812 | 14 | return Status::OK(); | 813 | 14 | }, | 814 | 14 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 14 | if (narrow_integral) { | 817 | 14 | block.get_by_position(result).column = | 818 | 14 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 14 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 14 | return Status::OK(); | 823 | 14 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 35 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 35 | using FromFieldType = typename FromDataType::FieldType; | 728 | 35 | using ToFieldType = typename ToDataType::FieldType; | 729 | 35 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 35 | const auto* col_from = | 731 | 35 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 35 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 35 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 35 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 35 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 35 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 35 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 35 | ToDataType::check_type_precision(to_precision); | 744 | 35 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 35 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 35 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 35 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 35 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 35 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 35 | constexpr UInt32 to_max_digits = | 755 | 35 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 35 | bool multiply_may_overflow = false; | 757 | 35 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 35 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 35 | sizeof(typename ToFieldType::NativeType)), | 762 | 35 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 35 | MaxNativeType scale_multiplier = | 764 | 35 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 35 | typename ToFieldType::NativeType max_result = | 766 | 35 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 35 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 35 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 35 | NullMap::value_type* null_map_data = nullptr; | 771 | 35 | if (narrow_integral) { | 772 | 35 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 35 | null_map_data = col_null_map_to->get_data().data(); | 774 | 35 | } | 775 | | | 776 | 35 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 35 | const auto& vec_from = col_from->get_data(); | 778 | 35 | const auto* vec_from_data = vec_from.data(); | 779 | 35 | auto& vec_to = col_to->get_data(); | 780 | 35 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 35 | CastParameters params; | 783 | 35 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 35 | size_t size = vec_from.size(); | 785 | | | 786 | 35 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 35 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 35 | } | 796 | | | 797 | 35 | RETURN_IF_ERROR(std::visit( | 798 | 35 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 35 | for (size_t i = 0; i < size; i++) { | 800 | 35 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 35 | typename ToDataType::FieldType, | 802 | 35 | multiply_may_overflow, narrow_integral>( | 803 | 35 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 35 | scale_multiplier, min_result, max_result, params)) { | 805 | 35 | if (set_nullable) { | 806 | 35 | null_map_data[i] = 1; | 807 | 35 | } else { | 808 | 35 | return params.status; | 809 | 35 | } | 810 | 35 | } | 811 | 35 | } | 812 | 35 | return Status::OK(); | 813 | 35 | }, | 814 | 35 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 7 | block.get_by_position(result).column = | 818 | 7 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 7 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 7 | return Status::OK(); | 823 | 35 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 14 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 14 | using FromFieldType = typename FromDataType::FieldType; | 728 | 14 | using ToFieldType = typename ToDataType::FieldType; | 729 | 14 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 14 | const auto* col_from = | 731 | 14 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 14 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 14 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 14 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 14 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 14 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 14 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 14 | ToDataType::check_type_precision(to_precision); | 744 | 14 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 14 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 14 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 14 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 14 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 14 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 14 | constexpr UInt32 to_max_digits = | 755 | 14 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 14 | bool multiply_may_overflow = false; | 757 | 14 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 14 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 14 | sizeof(typename ToFieldType::NativeType)), | 762 | 14 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 14 | MaxNativeType scale_multiplier = | 764 | 14 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 14 | typename ToFieldType::NativeType max_result = | 766 | 14 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 14 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 14 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 14 | NullMap::value_type* null_map_data = nullptr; | 771 | 14 | if (narrow_integral) { | 772 | 14 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 14 | null_map_data = col_null_map_to->get_data().data(); | 774 | 14 | } | 775 | | | 776 | 14 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 14 | const auto& vec_from = col_from->get_data(); | 778 | 14 | const auto* vec_from_data = vec_from.data(); | 779 | 14 | auto& vec_to = col_to->get_data(); | 780 | 14 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 14 | CastParameters params; | 783 | 14 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 14 | size_t size = vec_from.size(); | 785 | | | 786 | 14 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 14 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 14 | } | 796 | | | 797 | 14 | RETURN_IF_ERROR(std::visit( | 798 | 14 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 14 | for (size_t i = 0; i < size; i++) { | 800 | 14 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 14 | typename ToDataType::FieldType, | 802 | 14 | multiply_may_overflow, narrow_integral>( | 803 | 14 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 14 | scale_multiplier, min_result, max_result, params)) { | 805 | 14 | if (set_nullable) { | 806 | 14 | null_map_data[i] = 1; | 807 | 14 | } else { | 808 | 14 | return params.status; | 809 | 14 | } | 810 | 14 | } | 811 | 14 | } | 812 | 14 | return Status::OK(); | 813 | 14 | }, | 814 | 14 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 14 | if (narrow_integral) { | 817 | 14 | block.get_by_position(result).column = | 818 | 14 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 14 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 14 | return Status::OK(); | 823 | 14 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 35 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 35 | using FromFieldType = typename FromDataType::FieldType; | 728 | 35 | using ToFieldType = typename ToDataType::FieldType; | 729 | 35 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 35 | const auto* col_from = | 731 | 35 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 35 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 35 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 35 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 35 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 35 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 35 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 35 | ToDataType::check_type_precision(to_precision); | 744 | 35 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 35 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 35 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 35 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 35 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 35 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 35 | constexpr UInt32 to_max_digits = | 755 | 35 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 35 | bool multiply_may_overflow = false; | 757 | 35 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 35 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 35 | sizeof(typename ToFieldType::NativeType)), | 762 | 35 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 35 | MaxNativeType scale_multiplier = | 764 | 35 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 35 | typename ToFieldType::NativeType max_result = | 766 | 35 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 35 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 35 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 35 | NullMap::value_type* null_map_data = nullptr; | 771 | 35 | if (narrow_integral) { | 772 | 35 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 35 | null_map_data = col_null_map_to->get_data().data(); | 774 | 35 | } | 775 | | | 776 | 35 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 35 | const auto& vec_from = col_from->get_data(); | 778 | 35 | const auto* vec_from_data = vec_from.data(); | 779 | 35 | auto& vec_to = col_to->get_data(); | 780 | 35 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 35 | CastParameters params; | 783 | 35 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 35 | size_t size = vec_from.size(); | 785 | | | 786 | 35 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 35 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 35 | } | 796 | | | 797 | 35 | RETURN_IF_ERROR(std::visit( | 798 | 35 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 35 | for (size_t i = 0; i < size; i++) { | 800 | 35 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 35 | typename ToDataType::FieldType, | 802 | 35 | multiply_may_overflow, narrow_integral>( | 803 | 35 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 35 | scale_multiplier, min_result, max_result, params)) { | 805 | 35 | if (set_nullable) { | 806 | 35 | null_map_data[i] = 1; | 807 | 35 | } else { | 808 | 35 | return params.status; | 809 | 35 | } | 810 | 35 | } | 811 | 35 | } | 812 | 35 | return Status::OK(); | 813 | 35 | }, | 814 | 35 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 7 | block.get_by_position(result).column = | 818 | 7 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 7 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 7 | return Status::OK(); | 823 | 35 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 14 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 14 | using FromFieldType = typename FromDataType::FieldType; | 728 | 14 | using ToFieldType = typename ToDataType::FieldType; | 729 | 14 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 14 | const auto* col_from = | 731 | 14 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 14 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 14 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 14 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 14 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 14 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 14 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 14 | ToDataType::check_type_precision(to_precision); | 744 | 14 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 14 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 14 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 14 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 14 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 14 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 14 | constexpr UInt32 to_max_digits = | 755 | 14 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 14 | bool multiply_may_overflow = false; | 757 | 14 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 14 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 14 | sizeof(typename ToFieldType::NativeType)), | 762 | 14 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 14 | MaxNativeType scale_multiplier = | 764 | 14 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 14 | typename ToFieldType::NativeType max_result = | 766 | 14 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 14 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 14 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 14 | NullMap::value_type* null_map_data = nullptr; | 771 | 14 | if (narrow_integral) { | 772 | 14 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 14 | null_map_data = col_null_map_to->get_data().data(); | 774 | 14 | } | 775 | | | 776 | 14 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 14 | const auto& vec_from = col_from->get_data(); | 778 | 14 | const auto* vec_from_data = vec_from.data(); | 779 | 14 | auto& vec_to = col_to->get_data(); | 780 | 14 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 14 | CastParameters params; | 783 | 14 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 14 | size_t size = vec_from.size(); | 785 | | | 786 | 14 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 14 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 14 | } | 796 | | | 797 | 14 | RETURN_IF_ERROR(std::visit( | 798 | 14 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 14 | for (size_t i = 0; i < size; i++) { | 800 | 14 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 14 | typename ToDataType::FieldType, | 802 | 14 | multiply_may_overflow, narrow_integral>( | 803 | 14 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 14 | scale_multiplier, min_result, max_result, params)) { | 805 | 14 | if (set_nullable) { | 806 | 14 | null_map_data[i] = 1; | 807 | 14 | } else { | 808 | 14 | return params.status; | 809 | 14 | } | 810 | 14 | } | 811 | 14 | } | 812 | 14 | return Status::OK(); | 813 | 14 | }, | 814 | 14 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 14 | if (narrow_integral) { | 817 | 14 | block.get_by_position(result).column = | 818 | 14 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 14 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 14 | return Status::OK(); | 823 | 14 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 2 | using FromFieldType = typename FromDataType::FieldType; | 728 | 2 | using ToFieldType = typename ToDataType::FieldType; | 729 | 2 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 2 | const auto* col_from = | 731 | 2 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 2 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 2 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 2 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 2 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 2 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 2 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 2 | ToDataType::check_type_precision(to_precision); | 744 | 2 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 2 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 2 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 2 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 2 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 2 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 2 | constexpr UInt32 to_max_digits = | 755 | 2 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 2 | bool multiply_may_overflow = false; | 757 | 2 | if (to_scale > from_scale) { | 758 | 2 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 2 | } | 760 | 2 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 2 | sizeof(typename ToFieldType::NativeType)), | 762 | 2 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 2 | MaxNativeType scale_multiplier = | 764 | 2 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 2 | typename ToFieldType::NativeType max_result = | 766 | 2 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 2 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 2 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 2 | NullMap::value_type* null_map_data = nullptr; | 771 | 2 | if (narrow_integral) { | 772 | 2 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 2 | null_map_data = col_null_map_to->get_data().data(); | 774 | 2 | } | 775 | | | 776 | 2 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 2 | const auto& vec_from = col_from->get_data(); | 778 | 2 | const auto* vec_from_data = vec_from.data(); | 779 | 2 | auto& vec_to = col_to->get_data(); | 780 | 2 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 2 | CastParameters params; | 783 | 2 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 2 | size_t size = vec_from.size(); | 785 | | | 786 | 2 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 2 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 2 | } | 796 | | | 797 | 2 | RETURN_IF_ERROR(std::visit( | 798 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 2 | for (size_t i = 0; i < size; i++) { | 800 | 2 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 2 | typename ToDataType::FieldType, | 802 | 2 | multiply_may_overflow, narrow_integral>( | 803 | 2 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 2 | scale_multiplier, min_result, max_result, params)) { | 805 | 2 | if (set_nullable) { | 806 | 2 | null_map_data[i] = 1; | 807 | 2 | } else { | 808 | 2 | return params.status; | 809 | 2 | } | 810 | 2 | } | 811 | 2 | } | 812 | 2 | return Status::OK(); | 813 | 2 | }, | 814 | 2 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 1 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 1 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 1 | return Status::OK(); | 823 | 2 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 5 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 5 | using FromFieldType = typename FromDataType::FieldType; | 728 | 5 | using ToFieldType = typename ToDataType::FieldType; | 729 | 5 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 5 | const auto* col_from = | 731 | 5 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 5 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 5 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 5 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 5 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 5 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 5 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 5 | ToDataType::check_type_precision(to_precision); | 744 | 5 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 5 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 5 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 5 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 5 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 5 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 5 | constexpr UInt32 to_max_digits = | 755 | 5 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 5 | bool multiply_may_overflow = false; | 757 | 5 | if (to_scale > from_scale) { | 758 | 4 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 4 | } | 760 | 5 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 5 | sizeof(typename ToFieldType::NativeType)), | 762 | 5 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 5 | MaxNativeType scale_multiplier = | 764 | 5 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 5 | typename ToFieldType::NativeType max_result = | 766 | 5 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 5 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 5 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 5 | NullMap::value_type* null_map_data = nullptr; | 771 | 5 | if (narrow_integral) { | 772 | 1 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 1 | null_map_data = col_null_map_to->get_data().data(); | 774 | 1 | } | 775 | | | 776 | 5 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 5 | const auto& vec_from = col_from->get_data(); | 778 | 5 | const auto* vec_from_data = vec_from.data(); | 779 | 5 | auto& vec_to = col_to->get_data(); | 780 | 5 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 5 | CastParameters params; | 783 | 5 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 5 | size_t size = vec_from.size(); | 785 | | | 786 | 5 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 5 | if (to_scale == 0 && !narrow_integral) { | 788 | 3 | for (size_t i = 0; i < size; i++) { | 789 | 2 | vec_to_data[i].value = | 790 | 2 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 2 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 5 | } | 796 | | | 797 | 5 | RETURN_IF_ERROR(std::visit( | 798 | 5 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 5 | for (size_t i = 0; i < size; i++) { | 800 | 5 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 5 | typename ToDataType::FieldType, | 802 | 5 | multiply_may_overflow, narrow_integral>( | 803 | 5 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 5 | scale_multiplier, min_result, max_result, params)) { | 805 | 5 | if (set_nullable) { | 806 | 5 | null_map_data[i] = 1; | 807 | 5 | } else { | 808 | 5 | return params.status; | 809 | 5 | } | 810 | 5 | } | 811 | 5 | } | 812 | 5 | return Status::OK(); | 813 | 5 | }, | 814 | 5 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 5 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 5 | return Status::OK(); | 823 | 5 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 31 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 31 | using FromFieldType = typename FromDataType::FieldType; | 728 | 31 | using ToFieldType = typename ToDataType::FieldType; | 729 | 31 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 31 | const auto* col_from = | 731 | 31 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 31 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 31 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 31 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 31 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 31 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 31 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 31 | ToDataType::check_type_precision(to_precision); | 744 | 31 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 31 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 31 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 31 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 31 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 31 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 31 | constexpr UInt32 to_max_digits = | 755 | 31 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 31 | bool multiply_may_overflow = false; | 757 | 31 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 31 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 31 | sizeof(typename ToFieldType::NativeType)), | 762 | 31 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 31 | MaxNativeType scale_multiplier = | 764 | 31 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 31 | typename ToFieldType::NativeType max_result = | 766 | 31 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 31 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 31 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 31 | NullMap::value_type* null_map_data = nullptr; | 771 | 31 | if (narrow_integral) { | 772 | 30 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 30 | null_map_data = col_null_map_to->get_data().data(); | 774 | 30 | } | 775 | | | 776 | 31 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 31 | const auto& vec_from = col_from->get_data(); | 778 | 31 | const auto* vec_from_data = vec_from.data(); | 779 | 31 | auto& vec_to = col_to->get_data(); | 780 | 31 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 31 | CastParameters params; | 783 | 31 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 31 | size_t size = vec_from.size(); | 785 | | | 786 | 31 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 31 | if (to_scale == 0 && !narrow_integral) { | 788 | 10 | for (size_t i = 0; i < size; i++) { | 789 | 9 | vec_to_data[i].value = | 790 | 9 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 9 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 31 | } | 796 | | | 797 | 31 | RETURN_IF_ERROR(std::visit( | 798 | 31 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 31 | for (size_t i = 0; i < size; i++) { | 800 | 31 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 31 | typename ToDataType::FieldType, | 802 | 31 | multiply_may_overflow, narrow_integral>( | 803 | 31 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 31 | scale_multiplier, min_result, max_result, params)) { | 805 | 31 | if (set_nullable) { | 806 | 31 | null_map_data[i] = 1; | 807 | 31 | } else { | 808 | 31 | return params.status; | 809 | 31 | } | 810 | 31 | } | 811 | 31 | } | 812 | 31 | return Status::OK(); | 813 | 31 | }, | 814 | 31 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 1 | block.get_by_position(result).column = std::move(col_to); | 821 | 1 | } | 822 | 7 | return Status::OK(); | 823 | 31 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 13 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 13 | using FromFieldType = typename FromDataType::FieldType; | 728 | 13 | using ToFieldType = typename ToDataType::FieldType; | 729 | 13 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 13 | const auto* col_from = | 731 | 13 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 13 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 13 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 13 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 13 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 13 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 13 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 13 | ToDataType::check_type_precision(to_precision); | 744 | 13 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 13 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 13 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 13 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 13 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 13 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 13 | constexpr UInt32 to_max_digits = | 755 | 13 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 13 | bool multiply_may_overflow = false; | 757 | 13 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 13 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 13 | sizeof(typename ToFieldType::NativeType)), | 762 | 13 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 13 | MaxNativeType scale_multiplier = | 764 | 13 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 13 | typename ToFieldType::NativeType max_result = | 766 | 13 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 13 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 13 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 13 | NullMap::value_type* null_map_data = nullptr; | 771 | 13 | if (narrow_integral) { | 772 | 12 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 12 | null_map_data = col_null_map_to->get_data().data(); | 774 | 12 | } | 775 | | | 776 | 13 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 13 | const auto& vec_from = col_from->get_data(); | 778 | 13 | const auto* vec_from_data = vec_from.data(); | 779 | 13 | auto& vec_to = col_to->get_data(); | 780 | 13 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 13 | CastParameters params; | 783 | 13 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 13 | size_t size = vec_from.size(); | 785 | | | 786 | 13 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 13 | if (to_scale == 0 && !narrow_integral) { | 788 | 10 | for (size_t i = 0; i < size; i++) { | 789 | 9 | vec_to_data[i].value = | 790 | 9 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 9 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 13 | } | 796 | | | 797 | 13 | RETURN_IF_ERROR(std::visit( | 798 | 13 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 13 | for (size_t i = 0; i < size; i++) { | 800 | 13 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 13 | typename ToDataType::FieldType, | 802 | 13 | multiply_may_overflow, narrow_integral>( | 803 | 13 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 13 | scale_multiplier, min_result, max_result, params)) { | 805 | 13 | if (set_nullable) { | 806 | 13 | null_map_data[i] = 1; | 807 | 13 | } else { | 808 | 13 | return params.status; | 809 | 13 | } | 810 | 13 | } | 811 | 13 | } | 812 | 13 | return Status::OK(); | 813 | 13 | }, | 814 | 13 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 13 | if (narrow_integral) { | 817 | 12 | block.get_by_position(result).column = | 818 | 12 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 12 | } else { | 820 | 1 | block.get_by_position(result).column = std::move(col_to); | 821 | 1 | } | 822 | 13 | return Status::OK(); | 823 | 13 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 35 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 35 | using FromFieldType = typename FromDataType::FieldType; | 728 | 35 | using ToFieldType = typename ToDataType::FieldType; | 729 | 35 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 35 | const auto* col_from = | 731 | 35 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 35 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 35 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 35 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 35 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 35 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 35 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 35 | ToDataType::check_type_precision(to_precision); | 744 | 35 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 35 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 35 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 35 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 35 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 35 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 35 | constexpr UInt32 to_max_digits = | 755 | 35 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 35 | bool multiply_may_overflow = false; | 757 | 35 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 35 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 35 | sizeof(typename ToFieldType::NativeType)), | 762 | 35 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 35 | MaxNativeType scale_multiplier = | 764 | 35 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 35 | typename ToFieldType::NativeType max_result = | 766 | 35 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 35 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 35 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 35 | NullMap::value_type* null_map_data = nullptr; | 771 | 35 | if (narrow_integral) { | 772 | 35 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 35 | null_map_data = col_null_map_to->get_data().data(); | 774 | 35 | } | 775 | | | 776 | 35 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 35 | const auto& vec_from = col_from->get_data(); | 778 | 35 | const auto* vec_from_data = vec_from.data(); | 779 | 35 | auto& vec_to = col_to->get_data(); | 780 | 35 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 35 | CastParameters params; | 783 | 35 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 35 | size_t size = vec_from.size(); | 785 | | | 786 | 35 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 35 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 35 | } | 796 | | | 797 | 35 | RETURN_IF_ERROR(std::visit( | 798 | 35 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 35 | for (size_t i = 0; i < size; i++) { | 800 | 35 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 35 | typename ToDataType::FieldType, | 802 | 35 | multiply_may_overflow, narrow_integral>( | 803 | 35 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 35 | scale_multiplier, min_result, max_result, params)) { | 805 | 35 | if (set_nullable) { | 806 | 35 | null_map_data[i] = 1; | 807 | 35 | } else { | 808 | 35 | return params.status; | 809 | 35 | } | 810 | 35 | } | 811 | 35 | } | 812 | 35 | return Status::OK(); | 813 | 35 | }, | 814 | 35 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 7 | block.get_by_position(result).column = | 818 | 7 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 7 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 7 | return Status::OK(); | 823 | 35 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 14 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 14 | using FromFieldType = typename FromDataType::FieldType; | 728 | 14 | using ToFieldType = typename ToDataType::FieldType; | 729 | 14 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 14 | const auto* col_from = | 731 | 14 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 14 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 14 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 14 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 14 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 14 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 14 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 14 | ToDataType::check_type_precision(to_precision); | 744 | 14 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 14 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 14 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 14 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 14 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 14 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 14 | constexpr UInt32 to_max_digits = | 755 | 14 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 14 | bool multiply_may_overflow = false; | 757 | 14 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 14 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 14 | sizeof(typename ToFieldType::NativeType)), | 762 | 14 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 14 | MaxNativeType scale_multiplier = | 764 | 14 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 14 | typename ToFieldType::NativeType max_result = | 766 | 14 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 14 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 14 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 14 | NullMap::value_type* null_map_data = nullptr; | 771 | 14 | if (narrow_integral) { | 772 | 14 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 14 | null_map_data = col_null_map_to->get_data().data(); | 774 | 14 | } | 775 | | | 776 | 14 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 14 | const auto& vec_from = col_from->get_data(); | 778 | 14 | const auto* vec_from_data = vec_from.data(); | 779 | 14 | auto& vec_to = col_to->get_data(); | 780 | 14 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 14 | CastParameters params; | 783 | 14 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 14 | size_t size = vec_from.size(); | 785 | | | 786 | 14 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 14 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 14 | } | 796 | | | 797 | 14 | RETURN_IF_ERROR(std::visit( | 798 | 14 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 14 | for (size_t i = 0; i < size; i++) { | 800 | 14 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 14 | typename ToDataType::FieldType, | 802 | 14 | multiply_may_overflow, narrow_integral>( | 803 | 14 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 14 | scale_multiplier, min_result, max_result, params)) { | 805 | 14 | if (set_nullable) { | 806 | 14 | null_map_data[i] = 1; | 807 | 14 | } else { | 808 | 14 | return params.status; | 809 | 14 | } | 810 | 14 | } | 811 | 14 | } | 812 | 14 | return Status::OK(); | 813 | 14 | }, | 814 | 14 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 14 | if (narrow_integral) { | 817 | 14 | block.get_by_position(result).column = | 818 | 14 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 14 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 14 | return Status::OK(); | 823 | 14 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 35 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 35 | using FromFieldType = typename FromDataType::FieldType; | 728 | 35 | using ToFieldType = typename ToDataType::FieldType; | 729 | 35 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 35 | const auto* col_from = | 731 | 35 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 35 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 35 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 35 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 35 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 35 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 35 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 35 | ToDataType::check_type_precision(to_precision); | 744 | 35 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 35 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 35 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 35 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 35 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 35 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 35 | constexpr UInt32 to_max_digits = | 755 | 35 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 35 | bool multiply_may_overflow = false; | 757 | 35 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 35 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 35 | sizeof(typename ToFieldType::NativeType)), | 762 | 35 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 35 | MaxNativeType scale_multiplier = | 764 | 35 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 35 | typename ToFieldType::NativeType max_result = | 766 | 35 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 35 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 35 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 35 | NullMap::value_type* null_map_data = nullptr; | 771 | 35 | if (narrow_integral) { | 772 | 35 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 35 | null_map_data = col_null_map_to->get_data().data(); | 774 | 35 | } | 775 | | | 776 | 35 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 35 | const auto& vec_from = col_from->get_data(); | 778 | 35 | const auto* vec_from_data = vec_from.data(); | 779 | 35 | auto& vec_to = col_to->get_data(); | 780 | 35 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 35 | CastParameters params; | 783 | 35 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 35 | size_t size = vec_from.size(); | 785 | | | 786 | 35 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 35 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 35 | } | 796 | | | 797 | 35 | RETURN_IF_ERROR(std::visit( | 798 | 35 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 35 | for (size_t i = 0; i < size; i++) { | 800 | 35 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 35 | typename ToDataType::FieldType, | 802 | 35 | multiply_may_overflow, narrow_integral>( | 803 | 35 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 35 | scale_multiplier, min_result, max_result, params)) { | 805 | 35 | if (set_nullable) { | 806 | 35 | null_map_data[i] = 1; | 807 | 35 | } else { | 808 | 35 | return params.status; | 809 | 35 | } | 810 | 35 | } | 811 | 35 | } | 812 | 35 | return Status::OK(); | 813 | 35 | }, | 814 | 35 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 7 | block.get_by_position(result).column = | 818 | 7 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 7 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 7 | return Status::OK(); | 823 | 35 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 14 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 14 | using FromFieldType = typename FromDataType::FieldType; | 728 | 14 | using ToFieldType = typename ToDataType::FieldType; | 729 | 14 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 14 | const auto* col_from = | 731 | 14 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 14 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 14 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 14 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 14 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 14 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 14 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 14 | ToDataType::check_type_precision(to_precision); | 744 | 14 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 14 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 14 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 14 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 14 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 14 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 14 | constexpr UInt32 to_max_digits = | 755 | 14 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 14 | bool multiply_may_overflow = false; | 757 | 14 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 14 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 14 | sizeof(typename ToFieldType::NativeType)), | 762 | 14 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 14 | MaxNativeType scale_multiplier = | 764 | 14 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 14 | typename ToFieldType::NativeType max_result = | 766 | 14 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 14 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 14 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 14 | NullMap::value_type* null_map_data = nullptr; | 771 | 14 | if (narrow_integral) { | 772 | 14 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 14 | null_map_data = col_null_map_to->get_data().data(); | 774 | 14 | } | 775 | | | 776 | 14 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 14 | const auto& vec_from = col_from->get_data(); | 778 | 14 | const auto* vec_from_data = vec_from.data(); | 779 | 14 | auto& vec_to = col_to->get_data(); | 780 | 14 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 14 | CastParameters params; | 783 | 14 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 14 | size_t size = vec_from.size(); | 785 | | | 786 | 14 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 14 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 14 | } | 796 | | | 797 | 14 | RETURN_IF_ERROR(std::visit( | 798 | 14 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 14 | for (size_t i = 0; i < size; i++) { | 800 | 14 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 14 | typename ToDataType::FieldType, | 802 | 14 | multiply_may_overflow, narrow_integral>( | 803 | 14 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 14 | scale_multiplier, min_result, max_result, params)) { | 805 | 14 | if (set_nullable) { | 806 | 14 | null_map_data[i] = 1; | 807 | 14 | } else { | 808 | 14 | return params.status; | 809 | 14 | } | 810 | 14 | } | 811 | 14 | } | 812 | 14 | return Status::OK(); | 813 | 14 | }, | 814 | 14 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 14 | if (narrow_integral) { | 817 | 14 | block.get_by_position(result).column = | 818 | 14 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 14 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 14 | return Status::OK(); | 823 | 14 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 2 | using FromFieldType = typename FromDataType::FieldType; | 728 | 2 | using ToFieldType = typename ToDataType::FieldType; | 729 | 2 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 2 | const auto* col_from = | 731 | 2 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 2 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 2 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 2 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 2 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 2 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 2 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 2 | ToDataType::check_type_precision(to_precision); | 744 | 2 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 2 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 2 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 2 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 2 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 2 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 2 | constexpr UInt32 to_max_digits = | 755 | 2 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 2 | bool multiply_may_overflow = false; | 757 | 2 | if (to_scale > from_scale) { | 758 | 2 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 2 | } | 760 | 2 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 2 | sizeof(typename ToFieldType::NativeType)), | 762 | 2 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 2 | MaxNativeType scale_multiplier = | 764 | 2 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 2 | typename ToFieldType::NativeType max_result = | 766 | 2 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 2 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 2 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 2 | NullMap::value_type* null_map_data = nullptr; | 771 | 2 | if (narrow_integral) { | 772 | 2 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 2 | null_map_data = col_null_map_to->get_data().data(); | 774 | 2 | } | 775 | | | 776 | 2 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 2 | const auto& vec_from = col_from->get_data(); | 778 | 2 | const auto* vec_from_data = vec_from.data(); | 779 | 2 | auto& vec_to = col_to->get_data(); | 780 | 2 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 2 | CastParameters params; | 783 | 2 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 2 | size_t size = vec_from.size(); | 785 | | | 786 | 2 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 2 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 2 | } | 796 | | | 797 | 2 | RETURN_IF_ERROR(std::visit( | 798 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 2 | for (size_t i = 0; i < size; i++) { | 800 | 2 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 2 | typename ToDataType::FieldType, | 802 | 2 | multiply_may_overflow, narrow_integral>( | 803 | 2 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 2 | scale_multiplier, min_result, max_result, params)) { | 805 | 2 | if (set_nullable) { | 806 | 2 | null_map_data[i] = 1; | 807 | 2 | } else { | 808 | 2 | return params.status; | 809 | 2 | } | 810 | 2 | } | 811 | 2 | } | 812 | 2 | return Status::OK(); | 813 | 2 | }, | 814 | 2 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 1 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 1 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 1 | return Status::OK(); | 823 | 2 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 5 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 5 | using FromFieldType = typename FromDataType::FieldType; | 728 | 5 | using ToFieldType = typename ToDataType::FieldType; | 729 | 5 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 5 | const auto* col_from = | 731 | 5 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 5 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 5 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 5 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 5 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 5 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 5 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 5 | ToDataType::check_type_precision(to_precision); | 744 | 5 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 5 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 5 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 5 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 5 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 5 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 5 | constexpr UInt32 to_max_digits = | 755 | 5 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 5 | bool multiply_may_overflow = false; | 757 | 5 | if (to_scale > from_scale) { | 758 | 4 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 4 | } | 760 | 5 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 5 | sizeof(typename ToFieldType::NativeType)), | 762 | 5 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 5 | MaxNativeType scale_multiplier = | 764 | 5 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 5 | typename ToFieldType::NativeType max_result = | 766 | 5 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 5 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 5 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 5 | NullMap::value_type* null_map_data = nullptr; | 771 | 5 | if (narrow_integral) { | 772 | 1 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 1 | null_map_data = col_null_map_to->get_data().data(); | 774 | 1 | } | 775 | | | 776 | 5 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 5 | const auto& vec_from = col_from->get_data(); | 778 | 5 | const auto* vec_from_data = vec_from.data(); | 779 | 5 | auto& vec_to = col_to->get_data(); | 780 | 5 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 5 | CastParameters params; | 783 | 5 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 5 | size_t size = vec_from.size(); | 785 | | | 786 | 5 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 5 | if (to_scale == 0 && !narrow_integral) { | 788 | 3 | for (size_t i = 0; i < size; i++) { | 789 | 2 | vec_to_data[i].value = | 790 | 2 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 2 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 5 | } | 796 | | | 797 | 5 | RETURN_IF_ERROR(std::visit( | 798 | 5 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 5 | for (size_t i = 0; i < size; i++) { | 800 | 5 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 5 | typename ToDataType::FieldType, | 802 | 5 | multiply_may_overflow, narrow_integral>( | 803 | 5 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 5 | scale_multiplier, min_result, max_result, params)) { | 805 | 5 | if (set_nullable) { | 806 | 5 | null_map_data[i] = 1; | 807 | 5 | } else { | 808 | 5 | return params.status; | 809 | 5 | } | 810 | 5 | } | 811 | 5 | } | 812 | 5 | return Status::OK(); | 813 | 5 | }, | 814 | 5 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 5 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 5 | return Status::OK(); | 823 | 5 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 23 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 23 | using FromFieldType = typename FromDataType::FieldType; | 728 | 23 | using ToFieldType = typename ToDataType::FieldType; | 729 | 23 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 23 | const auto* col_from = | 731 | 23 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 23 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 23 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 23 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 23 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 23 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 23 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 23 | ToDataType::check_type_precision(to_precision); | 744 | 23 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 23 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 23 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 23 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 23 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 23 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 23 | constexpr UInt32 to_max_digits = | 755 | 23 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 23 | bool multiply_may_overflow = false; | 757 | 23 | if (to_scale > from_scale) { | 758 | 16 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 16 | } | 760 | 23 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 23 | sizeof(typename ToFieldType::NativeType)), | 762 | 23 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 23 | MaxNativeType scale_multiplier = | 764 | 23 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 23 | typename ToFieldType::NativeType max_result = | 766 | 23 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 23 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 23 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 23 | NullMap::value_type* null_map_data = nullptr; | 771 | 23 | if (narrow_integral) { | 772 | 20 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 20 | null_map_data = col_null_map_to->get_data().data(); | 774 | 20 | } | 775 | | | 776 | 23 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 23 | const auto& vec_from = col_from->get_data(); | 778 | 23 | const auto* vec_from_data = vec_from.data(); | 779 | 23 | auto& vec_to = col_to->get_data(); | 780 | 23 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 23 | CastParameters params; | 783 | 23 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 23 | size_t size = vec_from.size(); | 785 | | | 786 | 23 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 23 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 23 | } | 796 | | | 797 | 23 | RETURN_IF_ERROR(std::visit( | 798 | 23 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 23 | for (size_t i = 0; i < size; i++) { | 800 | 23 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 23 | typename ToDataType::FieldType, | 802 | 23 | multiply_may_overflow, narrow_integral>( | 803 | 23 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 23 | scale_multiplier, min_result, max_result, params)) { | 805 | 23 | if (set_nullable) { | 806 | 23 | null_map_data[i] = 1; | 807 | 23 | } else { | 808 | 23 | return params.status; | 809 | 23 | } | 810 | 23 | } | 811 | 23 | } | 812 | 23 | return Status::OK(); | 813 | 23 | }, | 814 | 23 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 4 | block.get_by_position(result).column = | 818 | 4 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 3 | block.get_by_position(result).column = std::move(col_to); | 821 | 3 | } | 822 | 7 | return Status::OK(); | 823 | 23 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 11 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 11 | using FromFieldType = typename FromDataType::FieldType; | 728 | 11 | using ToFieldType = typename ToDataType::FieldType; | 729 | 11 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 11 | const auto* col_from = | 731 | 11 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 11 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 11 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 11 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 11 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 11 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 11 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 11 | ToDataType::check_type_precision(to_precision); | 744 | 11 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 11 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 11 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 11 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 11 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 11 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 11 | constexpr UInt32 to_max_digits = | 755 | 11 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 11 | bool multiply_may_overflow = false; | 757 | 11 | if (to_scale > from_scale) { | 758 | 7 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 7 | } | 760 | 11 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 11 | sizeof(typename ToFieldType::NativeType)), | 762 | 11 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 11 | MaxNativeType scale_multiplier = | 764 | 11 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 11 | typename ToFieldType::NativeType max_result = | 766 | 11 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 11 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 11 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 11 | NullMap::value_type* null_map_data = nullptr; | 771 | 11 | if (narrow_integral) { | 772 | 8 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 8 | null_map_data = col_null_map_to->get_data().data(); | 774 | 8 | } | 775 | | | 776 | 11 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 11 | const auto& vec_from = col_from->get_data(); | 778 | 11 | const auto* vec_from_data = vec_from.data(); | 779 | 11 | auto& vec_to = col_to->get_data(); | 780 | 11 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 11 | CastParameters params; | 783 | 11 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 11 | size_t size = vec_from.size(); | 785 | | | 786 | 11 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 11 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 11 | } | 796 | | | 797 | 11 | RETURN_IF_ERROR(std::visit( | 798 | 11 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 11 | for (size_t i = 0; i < size; i++) { | 800 | 11 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 11 | typename ToDataType::FieldType, | 802 | 11 | multiply_may_overflow, narrow_integral>( | 803 | 11 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 11 | scale_multiplier, min_result, max_result, params)) { | 805 | 11 | if (set_nullable) { | 806 | 11 | null_map_data[i] = 1; | 807 | 11 | } else { | 808 | 11 | return params.status; | 809 | 11 | } | 810 | 11 | } | 811 | 11 | } | 812 | 11 | return Status::OK(); | 813 | 11 | }, | 814 | 11 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 11 | if (narrow_integral) { | 817 | 8 | block.get_by_position(result).column = | 818 | 8 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 8 | } else { | 820 | 3 | block.get_by_position(result).column = std::move(col_to); | 821 | 3 | } | 822 | 11 | return Status::OK(); | 823 | 11 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 35 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 35 | using FromFieldType = typename FromDataType::FieldType; | 728 | 35 | using ToFieldType = typename ToDataType::FieldType; | 729 | 35 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 35 | const auto* col_from = | 731 | 35 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 35 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 35 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 35 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 35 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 35 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 35 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 35 | ToDataType::check_type_precision(to_precision); | 744 | 35 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 35 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 35 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 35 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 35 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 35 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 35 | constexpr UInt32 to_max_digits = | 755 | 35 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 35 | bool multiply_may_overflow = false; | 757 | 35 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 35 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 35 | sizeof(typename ToFieldType::NativeType)), | 762 | 35 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 35 | MaxNativeType scale_multiplier = | 764 | 35 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 35 | typename ToFieldType::NativeType max_result = | 766 | 35 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 35 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 35 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 35 | NullMap::value_type* null_map_data = nullptr; | 771 | 35 | if (narrow_integral) { | 772 | 35 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 35 | null_map_data = col_null_map_to->get_data().data(); | 774 | 35 | } | 775 | | | 776 | 35 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 35 | const auto& vec_from = col_from->get_data(); | 778 | 35 | const auto* vec_from_data = vec_from.data(); | 779 | 35 | auto& vec_to = col_to->get_data(); | 780 | 35 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 35 | CastParameters params; | 783 | 35 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 35 | size_t size = vec_from.size(); | 785 | | | 786 | 35 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 35 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 35 | } | 796 | | | 797 | 35 | RETURN_IF_ERROR(std::visit( | 798 | 35 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 35 | for (size_t i = 0; i < size; i++) { | 800 | 35 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 35 | typename ToDataType::FieldType, | 802 | 35 | multiply_may_overflow, narrow_integral>( | 803 | 35 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 35 | scale_multiplier, min_result, max_result, params)) { | 805 | 35 | if (set_nullable) { | 806 | 35 | null_map_data[i] = 1; | 807 | 35 | } else { | 808 | 35 | return params.status; | 809 | 35 | } | 810 | 35 | } | 811 | 35 | } | 812 | 35 | return Status::OK(); | 813 | 35 | }, | 814 | 35 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 7 | block.get_by_position(result).column = | 818 | 7 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 7 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 7 | return Status::OK(); | 823 | 35 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 14 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 14 | using FromFieldType = typename FromDataType::FieldType; | 728 | 14 | using ToFieldType = typename ToDataType::FieldType; | 729 | 14 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 14 | const auto* col_from = | 731 | 14 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 14 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 14 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 14 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 14 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 14 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 14 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 14 | ToDataType::check_type_precision(to_precision); | 744 | 14 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 14 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 14 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 14 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 14 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 14 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 14 | constexpr UInt32 to_max_digits = | 755 | 14 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 14 | bool multiply_may_overflow = false; | 757 | 14 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 14 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 14 | sizeof(typename ToFieldType::NativeType)), | 762 | 14 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 14 | MaxNativeType scale_multiplier = | 764 | 14 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 14 | typename ToFieldType::NativeType max_result = | 766 | 14 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 14 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 14 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 14 | NullMap::value_type* null_map_data = nullptr; | 771 | 14 | if (narrow_integral) { | 772 | 14 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 14 | null_map_data = col_null_map_to->get_data().data(); | 774 | 14 | } | 775 | | | 776 | 14 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 14 | const auto& vec_from = col_from->get_data(); | 778 | 14 | const auto* vec_from_data = vec_from.data(); | 779 | 14 | auto& vec_to = col_to->get_data(); | 780 | 14 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 14 | CastParameters params; | 783 | 14 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 14 | size_t size = vec_from.size(); | 785 | | | 786 | 14 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 14 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 14 | } | 796 | | | 797 | 14 | RETURN_IF_ERROR(std::visit( | 798 | 14 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 14 | for (size_t i = 0; i < size; i++) { | 800 | 14 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 14 | typename ToDataType::FieldType, | 802 | 14 | multiply_may_overflow, narrow_integral>( | 803 | 14 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 14 | scale_multiplier, min_result, max_result, params)) { | 805 | 14 | if (set_nullable) { | 806 | 14 | null_map_data[i] = 1; | 807 | 14 | } else { | 808 | 14 | return params.status; | 809 | 14 | } | 810 | 14 | } | 811 | 14 | } | 812 | 14 | return Status::OK(); | 813 | 14 | }, | 814 | 14 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 14 | if (narrow_integral) { | 817 | 14 | block.get_by_position(result).column = | 818 | 14 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 14 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 14 | return Status::OK(); | 823 | 14 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 2 | using FromFieldType = typename FromDataType::FieldType; | 728 | 2 | using ToFieldType = typename ToDataType::FieldType; | 729 | 2 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 2 | const auto* col_from = | 731 | 2 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 2 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 2 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 2 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 2 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 2 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 2 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 2 | ToDataType::check_type_precision(to_precision); | 744 | 2 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 2 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 2 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 2 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 2 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 2 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 2 | constexpr UInt32 to_max_digits = | 755 | 2 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 2 | bool multiply_may_overflow = false; | 757 | 2 | if (to_scale > from_scale) { | 758 | 2 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 2 | } | 760 | 2 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 2 | sizeof(typename ToFieldType::NativeType)), | 762 | 2 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 2 | MaxNativeType scale_multiplier = | 764 | 2 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 2 | typename ToFieldType::NativeType max_result = | 766 | 2 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 2 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 2 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 2 | NullMap::value_type* null_map_data = nullptr; | 771 | 2 | if (narrow_integral) { | 772 | 2 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 2 | null_map_data = col_null_map_to->get_data().data(); | 774 | 2 | } | 775 | | | 776 | 2 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 2 | const auto& vec_from = col_from->get_data(); | 778 | 2 | const auto* vec_from_data = vec_from.data(); | 779 | 2 | auto& vec_to = col_to->get_data(); | 780 | 2 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 2 | CastParameters params; | 783 | 2 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 2 | size_t size = vec_from.size(); | 785 | | | 786 | 2 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 2 | if (to_scale == 0 && !narrow_integral) { | 788 | 0 | for (size_t i = 0; i < size; i++) { | 789 | 0 | vec_to_data[i].value = | 790 | 0 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 0 | } | 792 | 0 | block.get_by_position(result).column = std::move(col_to); | 793 | 0 | return Status::OK(); | 794 | 0 | } | 795 | 2 | } | 796 | | | 797 | 2 | RETURN_IF_ERROR(std::visit( | 798 | 2 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 2 | for (size_t i = 0; i < size; i++) { | 800 | 2 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 2 | typename ToDataType::FieldType, | 802 | 2 | multiply_may_overflow, narrow_integral>( | 803 | 2 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 2 | scale_multiplier, min_result, max_result, params)) { | 805 | 2 | if (set_nullable) { | 806 | 2 | null_map_data[i] = 1; | 807 | 2 | } else { | 808 | 2 | return params.status; | 809 | 2 | } | 810 | 2 | } | 811 | 2 | } | 812 | 2 | return Status::OK(); | 813 | 2 | }, | 814 | 2 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 1 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 1 | } else { | 820 | 0 | block.get_by_position(result).column = std::move(col_to); | 821 | 0 | } | 822 | 1 | return Status::OK(); | 823 | 2 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 5 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 5 | using FromFieldType = typename FromDataType::FieldType; | 728 | 5 | using ToFieldType = typename ToDataType::FieldType; | 729 | 5 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 5 | const auto* col_from = | 731 | 5 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 5 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 5 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 5 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 5 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 5 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 5 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 5 | ToDataType::check_type_precision(to_precision); | 744 | 5 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 5 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 5 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 5 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 5 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 5 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 5 | constexpr UInt32 to_max_digits = | 755 | 5 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 5 | bool multiply_may_overflow = false; | 757 | 5 | if (to_scale > from_scale) { | 758 | 4 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 4 | } | 760 | 5 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 5 | sizeof(typename ToFieldType::NativeType)), | 762 | 5 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 5 | MaxNativeType scale_multiplier = | 764 | 5 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 5 | typename ToFieldType::NativeType max_result = | 766 | 5 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 5 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 5 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 5 | NullMap::value_type* null_map_data = nullptr; | 771 | 5 | if (narrow_integral) { | 772 | 1 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 1 | null_map_data = col_null_map_to->get_data().data(); | 774 | 1 | } | 775 | | | 776 | 5 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 5 | const auto& vec_from = col_from->get_data(); | 778 | 5 | const auto* vec_from_data = vec_from.data(); | 779 | 5 | auto& vec_to = col_to->get_data(); | 780 | 5 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 5 | CastParameters params; | 783 | 5 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 5 | size_t size = vec_from.size(); | 785 | | | 786 | 5 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 5 | if (to_scale == 0 && !narrow_integral) { | 788 | 3 | for (size_t i = 0; i < size; i++) { | 789 | 2 | vec_to_data[i].value = | 790 | 2 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 2 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 5 | } | 796 | | | 797 | 5 | RETURN_IF_ERROR(std::visit( | 798 | 5 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 5 | for (size_t i = 0; i < size; i++) { | 800 | 5 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 5 | typename ToDataType::FieldType, | 802 | 5 | multiply_may_overflow, narrow_integral>( | 803 | 5 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 5 | scale_multiplier, min_result, max_result, params)) { | 805 | 5 | if (set_nullable) { | 806 | 5 | null_map_data[i] = 1; | 807 | 5 | } else { | 808 | 5 | return params.status; | 809 | 5 | } | 810 | 5 | } | 811 | 5 | } | 812 | 5 | return Status::OK(); | 813 | 5 | }, | 814 | 5 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 5 | if (narrow_integral) { | 817 | 1 | block.get_by_position(result).column = | 818 | 1 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 5 | return Status::OK(); | 823 | 5 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 19 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 19 | using FromFieldType = typename FromDataType::FieldType; | 728 | 19 | using ToFieldType = typename ToDataType::FieldType; | 729 | 19 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 19 | const auto* col_from = | 731 | 19 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 19 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 19 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 19 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 19 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 19 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 19 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 19 | ToDataType::check_type_precision(to_precision); | 744 | 19 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 19 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 19 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 19 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 19 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 19 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 19 | constexpr UInt32 to_max_digits = | 755 | 19 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 19 | bool multiply_may_overflow = false; | 757 | 19 | if (to_scale > from_scale) { | 758 | 12 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 12 | } | 760 | 19 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 19 | sizeof(typename ToFieldType::NativeType)), | 762 | 19 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 19 | MaxNativeType scale_multiplier = | 764 | 19 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 19 | typename ToFieldType::NativeType max_result = | 766 | 19 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 19 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 19 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 19 | NullMap::value_type* null_map_data = nullptr; | 771 | 19 | if (narrow_integral) { | 772 | 15 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 15 | null_map_data = col_null_map_to->get_data().data(); | 774 | 15 | } | 775 | | | 776 | 19 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 19 | const auto& vec_from = col_from->get_data(); | 778 | 19 | const auto* vec_from_data = vec_from.data(); | 779 | 19 | auto& vec_to = col_to->get_data(); | 780 | 19 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 19 | CastParameters params; | 783 | 19 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 19 | size_t size = vec_from.size(); | 785 | | | 786 | 19 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 19 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 19 | } | 796 | | | 797 | 19 | RETURN_IF_ERROR(std::visit( | 798 | 19 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 19 | for (size_t i = 0; i < size; i++) { | 800 | 19 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 19 | typename ToDataType::FieldType, | 802 | 19 | multiply_may_overflow, narrow_integral>( | 803 | 19 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 19 | scale_multiplier, min_result, max_result, params)) { | 805 | 19 | if (set_nullable) { | 806 | 19 | null_map_data[i] = 1; | 807 | 19 | } else { | 808 | 19 | return params.status; | 809 | 19 | } | 810 | 19 | } | 811 | 19 | } | 812 | 19 | return Status::OK(); | 813 | 19 | }, | 814 | 19 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 3 | block.get_by_position(result).column = | 818 | 3 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 4 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 7 | return Status::OK(); | 823 | 19 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 10 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 10 | using FromFieldType = typename FromDataType::FieldType; | 728 | 10 | using ToFieldType = typename ToDataType::FieldType; | 729 | 10 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 10 | const auto* col_from = | 731 | 10 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 10 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 10 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 10 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 10 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 10 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 10 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 10 | ToDataType::check_type_precision(to_precision); | 744 | 10 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 10 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 10 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 10 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 10 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 10 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 10 | constexpr UInt32 to_max_digits = | 755 | 10 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 10 | bool multiply_may_overflow = false; | 757 | 10 | if (to_scale > from_scale) { | 758 | 6 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 6 | } | 760 | 10 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 10 | sizeof(typename ToFieldType::NativeType)), | 762 | 10 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 10 | MaxNativeType scale_multiplier = | 764 | 10 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 10 | typename ToFieldType::NativeType max_result = | 766 | 10 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 10 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 10 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 10 | NullMap::value_type* null_map_data = nullptr; | 771 | 10 | if (narrow_integral) { | 772 | 6 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 6 | null_map_data = col_null_map_to->get_data().data(); | 774 | 6 | } | 775 | | | 776 | 10 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 10 | const auto& vec_from = col_from->get_data(); | 778 | 10 | const auto* vec_from_data = vec_from.data(); | 779 | 10 | auto& vec_to = col_to->get_data(); | 780 | 10 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 10 | CastParameters params; | 783 | 10 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 10 | size_t size = vec_from.size(); | 785 | | | 786 | 10 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 10 | if (to_scale == 0 && !narrow_integral) { | 788 | 20 | for (size_t i = 0; i < size; i++) { | 789 | 18 | vec_to_data[i].value = | 790 | 18 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 18 | } | 792 | 2 | block.get_by_position(result).column = std::move(col_to); | 793 | 2 | return Status::OK(); | 794 | 2 | } | 795 | 10 | } | 796 | | | 797 | 10 | RETURN_IF_ERROR(std::visit( | 798 | 10 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 10 | for (size_t i = 0; i < size; i++) { | 800 | 10 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 10 | typename ToDataType::FieldType, | 802 | 10 | multiply_may_overflow, narrow_integral>( | 803 | 10 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 10 | scale_multiplier, min_result, max_result, params)) { | 805 | 10 | if (set_nullable) { | 806 | 10 | null_map_data[i] = 1; | 807 | 10 | } else { | 808 | 10 | return params.status; | 809 | 10 | } | 810 | 10 | } | 811 | 10 | } | 812 | 10 | return Status::OK(); | 813 | 10 | }, | 814 | 10 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 10 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 4 | block.get_by_position(result).column = std::move(col_to); | 821 | 4 | } | 822 | 10 | return Status::OK(); | 823 | 10 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 31 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 31 | using FromFieldType = typename FromDataType::FieldType; | 728 | 31 | using ToFieldType = typename ToDataType::FieldType; | 729 | 31 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 31 | const auto* col_from = | 731 | 31 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 31 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 31 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 31 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 31 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 31 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 31 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 31 | ToDataType::check_type_precision(to_precision); | 744 | 31 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 31 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 31 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 31 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 31 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 31 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 31 | constexpr UInt32 to_max_digits = | 755 | 31 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 31 | bool multiply_may_overflow = false; | 757 | 31 | if (to_scale > from_scale) { | 758 | 20 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 20 | } | 760 | 31 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 31 | sizeof(typename ToFieldType::NativeType)), | 762 | 31 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 31 | MaxNativeType scale_multiplier = | 764 | 31 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 31 | typename ToFieldType::NativeType max_result = | 766 | 31 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 31 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 31 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 31 | NullMap::value_type* null_map_data = nullptr; | 771 | 31 | if (narrow_integral) { | 772 | 30 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 30 | null_map_data = col_null_map_to->get_data().data(); | 774 | 30 | } | 775 | | | 776 | 31 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 31 | const auto& vec_from = col_from->get_data(); | 778 | 31 | const auto* vec_from_data = vec_from.data(); | 779 | 31 | auto& vec_to = col_to->get_data(); | 780 | 31 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 31 | CastParameters params; | 783 | 31 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 31 | size_t size = vec_from.size(); | 785 | | | 786 | 31 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 31 | if (to_scale == 0 && !narrow_integral) { | 788 | 10 | for (size_t i = 0; i < size; i++) { | 789 | 9 | vec_to_data[i].value = | 790 | 9 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 9 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 31 | } | 796 | | | 797 | 31 | RETURN_IF_ERROR(std::visit( | 798 | 31 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 31 | for (size_t i = 0; i < size; i++) { | 800 | 31 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 31 | typename ToDataType::FieldType, | 802 | 31 | multiply_may_overflow, narrow_integral>( | 803 | 31 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 31 | scale_multiplier, min_result, max_result, params)) { | 805 | 31 | if (set_nullable) { | 806 | 31 | null_map_data[i] = 1; | 807 | 31 | } else { | 808 | 31 | return params.status; | 809 | 31 | } | 810 | 31 | } | 811 | 31 | } | 812 | 31 | return Status::OK(); | 813 | 31 | }, | 814 | 31 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 7 | if (narrow_integral) { | 817 | 6 | block.get_by_position(result).column = | 818 | 6 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 6 | } else { | 820 | 1 | block.get_by_position(result).column = std::move(col_to); | 821 | 1 | } | 822 | 7 | return Status::OK(); | 823 | 31 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 726 | 13 | const NullMap::value_type* null_map = nullptr) const override { | 727 | 13 | using FromFieldType = typename FromDataType::FieldType; | 728 | 13 | using ToFieldType = typename ToDataType::FieldType; | 729 | 13 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 730 | 13 | const auto* col_from = | 731 | 13 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 732 | 13 | if (!col_from) { | 733 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 734 | 0 | named_from.column->get_name()); | 735 | 0 | } | 736 | | | 737 | 13 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 738 | 13 | constexpr UInt32 from_scale = 0; | 739 | | | 740 | 13 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 741 | 13 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 742 | 13 | UInt32 to_precision = to_decimal_type.get_precision(); | 743 | 13 | ToDataType::check_type_precision(to_precision); | 744 | 13 | UInt32 to_scale = to_decimal_type.get_scale(); | 745 | 13 | ToDataType::check_type_scale(to_scale); | 746 | | | 747 | 13 | auto from_max_int_digit_count = from_precision - from_scale; | 748 | 13 | auto to_max_int_digit_count = to_precision - to_scale; | 749 | | // may overflow. nullable result column. | 750 | 13 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count); | 751 | | // only in non-strict mode and may overflow, we set nullable | 752 | 13 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 753 | | | 754 | 13 | constexpr UInt32 to_max_digits = | 755 | 13 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 756 | 13 | bool multiply_may_overflow = false; | 757 | 13 | if (to_scale > from_scale) { | 758 | 8 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 759 | 8 | } | 760 | 13 | using MaxNativeType = std::conditional_t<(sizeof(FromFieldType) > | 761 | 13 | sizeof(typename ToFieldType::NativeType)), | 762 | 13 | FromFieldType, typename ToFieldType::NativeType>; | 763 | 13 | MaxNativeType scale_multiplier = | 764 | 13 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 765 | 13 | typename ToFieldType::NativeType max_result = | 766 | 13 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 767 | 13 | typename ToFieldType::NativeType min_result = -max_result; | 768 | | | 769 | 13 | ColumnUInt8::MutablePtr col_null_map_to; | 770 | 13 | NullMap::value_type* null_map_data = nullptr; | 771 | 13 | if (narrow_integral) { | 772 | 12 | col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 773 | 12 | null_map_data = col_null_map_to->get_data().data(); | 774 | 12 | } | 775 | | | 776 | 13 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 777 | 13 | const auto& vec_from = col_from->get_data(); | 778 | 13 | const auto* vec_from_data = vec_from.data(); | 779 | 13 | auto& vec_to = col_to->get_data(); | 780 | 13 | auto* vec_to_data = vec_to.data(); | 781 | | | 782 | 13 | CastParameters params; | 783 | 13 | params.is_strict = (CastMode == CastModeType::StrictMode); | 784 | 13 | size_t size = vec_from.size(); | 785 | | | 786 | 13 | if constexpr (IsDataTypeDecimalV3<ToDataType>) { | 787 | 13 | if (to_scale == 0 && !narrow_integral) { | 788 | 10 | for (size_t i = 0; i < size; i++) { | 789 | 9 | vec_to_data[i].value = | 790 | 9 | static_cast<typename ToFieldType::NativeType>(vec_from_data[i]); | 791 | 9 | } | 792 | 1 | block.get_by_position(result).column = std::move(col_to); | 793 | 1 | return Status::OK(); | 794 | 1 | } | 795 | 13 | } | 796 | | | 797 | 13 | RETURN_IF_ERROR(std::visit( | 798 | 13 | [&](auto multiply_may_overflow, auto narrow_integral) { | 799 | 13 | for (size_t i = 0; i < size; i++) { | 800 | 13 | if (!CastToDecimal::_from_int<typename FromDataType::FieldType, | 801 | 13 | typename ToDataType::FieldType, | 802 | 13 | multiply_may_overflow, narrow_integral>( | 803 | 13 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, | 804 | 13 | scale_multiplier, min_result, max_result, params)) { | 805 | 13 | if (set_nullable) { | 806 | 13 | null_map_data[i] = 1; | 807 | 13 | } else { | 808 | 13 | return params.status; | 809 | 13 | } | 810 | 13 | } | 811 | 13 | } | 812 | 13 | return Status::OK(); | 813 | 13 | }, | 814 | 13 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 815 | | | 816 | 13 | if (narrow_integral) { | 817 | 12 | block.get_by_position(result).column = | 818 | 12 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 819 | 12 | } else { | 820 | 1 | block.get_by_position(result).column = std::move(col_to); | 821 | 1 | } | 822 | 13 | return Status::OK(); | 823 | 13 | } |
|
824 | | }; |
825 | | |
826 | | // cast float and double to decimal. ALWAYS nullable result column. |
827 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
828 | | requires(IsDataTypeDecimal<ToDataType> && IsDataTypeFloat<FromDataType>) |
829 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
830 | | public: |
831 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
832 | | uint32_t result, size_t input_rows_count, |
833 | 796 | const NullMap::value_type* null_map = nullptr) const override { |
834 | 796 | using FromFieldType = typename FromDataType::FieldType; |
835 | 796 | using ToFieldType = typename ToDataType::FieldType; |
836 | 796 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); |
837 | 796 | const auto* col_from = |
838 | 796 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); |
839 | 796 | if (!col_from) { |
840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", |
841 | 0 | named_from.column->get_name()); |
842 | 0 | } |
843 | | |
844 | 796 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); |
845 | 796 | UInt32 from_scale = 0; |
846 | | |
847 | 796 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); |
848 | 796 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); |
849 | 796 | UInt32 to_precision = to_decimal_type.get_precision(); |
850 | 796 | ToDataType::check_type_precision(to_precision); |
851 | 796 | UInt32 to_scale = to_decimal_type.get_scale(); |
852 | 796 | ToDataType::check_type_scale(to_scale); |
853 | | |
854 | 796 | auto from_max_int_digit_count = from_precision - from_scale; |
855 | 796 | auto to_max_int_digit_count = to_precision - to_scale; |
856 | 796 | bool narrow_integral = |
857 | 796 | (to_max_int_digit_count < from_max_int_digit_count) || |
858 | 796 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); |
859 | | // only in non-strict mode and may overflow, we set nullable |
860 | 796 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; |
861 | | |
862 | 796 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); |
863 | 796 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); |
864 | | |
865 | 796 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); |
866 | 796 | const auto& vec_from = col_from->get_data(); |
867 | 796 | const auto* vec_from_data = vec_from.data(); |
868 | 796 | auto& vec_to = col_to->get_data(); |
869 | 796 | auto* vec_to_data = vec_to.data(); |
870 | | |
871 | 796 | CastParameters params; |
872 | 796 | params.is_strict = (CastMode == CastModeType::StrictMode); |
873 | 796 | size_t size = vec_from.size(); |
874 | | |
875 | 796 | typename ToFieldType::NativeType scale_multiplier = |
876 | 796 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); |
877 | 796 | typename ToFieldType::NativeType max_result = |
878 | 796 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); |
879 | 796 | typename ToFieldType::NativeType min_result = -max_result; |
880 | 4.02k | for (size_t i = 0; i < size; i++) { |
881 | 3.37k | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, |
882 | 3.37k | typename ToDataType::FieldType>( |
883 | 3.37k | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, |
884 | 3.37k | min_result, max_result, params)) { |
885 | 288 | if (set_nullable) { |
886 | 144 | null_map_data[i] = 1; |
887 | 144 | } else { |
888 | 144 | return params.status; |
889 | 144 | } |
890 | 288 | } |
891 | 3.37k | } |
892 | | |
893 | 652 | block.get_by_position(result).column = |
894 | 652 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); |
895 | 652 | return Status::OK(); |
896 | 796 | } Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_20EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 81 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 81 | using FromFieldType = typename FromDataType::FieldType; | 835 | 81 | using ToFieldType = typename ToDataType::FieldType; | 836 | 81 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 81 | const auto* col_from = | 838 | 81 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 81 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 81 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 81 | UInt32 from_scale = 0; | 846 | | | 847 | 81 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 81 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 81 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 81 | ToDataType::check_type_precision(to_precision); | 851 | 81 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 81 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 81 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 81 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 81 | bool narrow_integral = | 857 | 81 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 81 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 81 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 81 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 81 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 81 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 81 | const auto& vec_from = col_from->get_data(); | 867 | 81 | const auto* vec_from_data = vec_from.data(); | 868 | 81 | auto& vec_to = col_to->get_data(); | 869 | 81 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 81 | CastParameters params; | 872 | 81 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 81 | size_t size = vec_from.size(); | 874 | | | 875 | 81 | typename ToFieldType::NativeType scale_multiplier = | 876 | 81 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 81 | typename ToFieldType::NativeType max_result = | 878 | 81 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 81 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 491 | for (size_t i = 0; i < size; i++) { | 881 | 410 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 410 | typename ToDataType::FieldType>( | 883 | 410 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 410 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 410 | } | 892 | | | 893 | 81 | block.get_by_position(result).column = | 894 | 81 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 81 | return Status::OK(); | 896 | 81 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 89 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 89 | using FromFieldType = typename FromDataType::FieldType; | 835 | 89 | using ToFieldType = typename ToDataType::FieldType; | 836 | 89 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 89 | const auto* col_from = | 838 | 89 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 89 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 89 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 89 | UInt32 from_scale = 0; | 846 | | | 847 | 89 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 89 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 89 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 89 | ToDataType::check_type_precision(to_precision); | 851 | 89 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 89 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 89 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 89 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 89 | bool narrow_integral = | 857 | 89 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 89 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 89 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 89 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 89 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 89 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 89 | const auto& vec_from = col_from->get_data(); | 867 | 89 | const auto* vec_from_data = vec_from.data(); | 868 | 89 | auto& vec_to = col_to->get_data(); | 869 | 89 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 89 | CastParameters params; | 872 | 89 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 89 | size_t size = vec_from.size(); | 874 | | | 875 | 89 | typename ToFieldType::NativeType scale_multiplier = | 876 | 89 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 89 | typename ToFieldType::NativeType max_result = | 878 | 89 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 89 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 523 | for (size_t i = 0; i < size; i++) { | 881 | 434 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 434 | typename ToDataType::FieldType>( | 883 | 434 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 434 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 434 | } | 892 | | | 893 | 89 | block.get_by_position(result).column = | 894 | 89 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 89 | return Status::OK(); | 896 | 89 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 81 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 81 | using FromFieldType = typename FromDataType::FieldType; | 835 | 81 | using ToFieldType = typename ToDataType::FieldType; | 836 | 81 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 81 | const auto* col_from = | 838 | 81 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 81 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 81 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 81 | UInt32 from_scale = 0; | 846 | | | 847 | 81 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 81 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 81 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 81 | ToDataType::check_type_precision(to_precision); | 851 | 81 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 81 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 81 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 81 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 81 | bool narrow_integral = | 857 | 81 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 81 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 81 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 81 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 81 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 81 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 81 | const auto& vec_from = col_from->get_data(); | 867 | 81 | const auto* vec_from_data = vec_from.data(); | 868 | 81 | auto& vec_to = col_to->get_data(); | 869 | 81 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 81 | CastParameters params; | 872 | 81 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 81 | size_t size = vec_from.size(); | 874 | | | 875 | 81 | typename ToFieldType::NativeType scale_multiplier = | 876 | 81 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 81 | typename ToFieldType::NativeType max_result = | 878 | 81 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 81 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 443 | for (size_t i = 0; i < size; i++) { | 881 | 362 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 362 | typename ToDataType::FieldType>( | 883 | 362 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 362 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 362 | } | 892 | | | 893 | 81 | block.get_by_position(result).column = | 894 | 81 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 81 | return Status::OK(); | 896 | 81 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 81 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 81 | using FromFieldType = typename FromDataType::FieldType; | 835 | 81 | using ToFieldType = typename ToDataType::FieldType; | 836 | 81 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 81 | const auto* col_from = | 838 | 81 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 81 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 81 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 81 | UInt32 from_scale = 0; | 846 | | | 847 | 81 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 81 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 81 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 81 | ToDataType::check_type_precision(to_precision); | 851 | 81 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 81 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 81 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 81 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 81 | bool narrow_integral = | 857 | 81 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 81 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 81 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 81 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 81 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 81 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 81 | const auto& vec_from = col_from->get_data(); | 867 | 81 | const auto* vec_from_data = vec_from.data(); | 868 | 81 | auto& vec_to = col_to->get_data(); | 869 | 81 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 81 | CastParameters params; | 872 | 81 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 81 | size_t size = vec_from.size(); | 874 | | | 875 | 81 | typename ToFieldType::NativeType scale_multiplier = | 876 | 81 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 81 | typename ToFieldType::NativeType max_result = | 878 | 81 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 81 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 491 | for (size_t i = 0; i < size; i++) { | 881 | 410 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 410 | typename ToDataType::FieldType>( | 883 | 410 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 410 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 410 | } | 892 | | | 893 | 81 | block.get_by_position(result).column = | 894 | 81 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 81 | return Status::OK(); | 896 | 81 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 89 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 89 | using FromFieldType = typename FromDataType::FieldType; | 835 | 89 | using ToFieldType = typename ToDataType::FieldType; | 836 | 89 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 89 | const auto* col_from = | 838 | 89 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 89 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 89 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 89 | UInt32 from_scale = 0; | 846 | | | 847 | 89 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 89 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 89 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 89 | ToDataType::check_type_precision(to_precision); | 851 | 89 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 89 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 89 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 89 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 89 | bool narrow_integral = | 857 | 89 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 89 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 89 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 89 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 89 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 89 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 89 | const auto& vec_from = col_from->get_data(); | 867 | 89 | const auto* vec_from_data = vec_from.data(); | 868 | 89 | auto& vec_to = col_to->get_data(); | 869 | 89 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 89 | CastParameters params; | 872 | 89 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 89 | size_t size = vec_from.size(); | 874 | | | 875 | 89 | typename ToFieldType::NativeType scale_multiplier = | 876 | 89 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 89 | typename ToFieldType::NativeType max_result = | 878 | 89 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 89 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 515 | for (size_t i = 0; i < size; i++) { | 881 | 426 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 426 | typename ToDataType::FieldType>( | 883 | 426 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 426 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 426 | } | 892 | | | 893 | 89 | block.get_by_position(result).column = | 894 | 89 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 89 | return Status::OK(); | 896 | 89 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 81 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 81 | using FromFieldType = typename FromDataType::FieldType; | 835 | 81 | using ToFieldType = typename ToDataType::FieldType; | 836 | 81 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 81 | const auto* col_from = | 838 | 81 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 81 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 81 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 81 | UInt32 from_scale = 0; | 846 | | | 847 | 81 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 81 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 81 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 81 | ToDataType::check_type_precision(to_precision); | 851 | 81 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 81 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 81 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 81 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 81 | bool narrow_integral = | 857 | 81 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 81 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 81 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 81 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 81 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 81 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 81 | const auto& vec_from = col_from->get_data(); | 867 | 81 | const auto* vec_from_data = vec_from.data(); | 868 | 81 | auto& vec_to = col_to->get_data(); | 869 | 81 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 81 | CastParameters params; | 872 | 81 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 81 | size_t size = vec_from.size(); | 874 | | | 875 | 81 | typename ToFieldType::NativeType scale_multiplier = | 876 | 81 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 81 | typename ToFieldType::NativeType max_result = | 878 | 81 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 81 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 443 | for (size_t i = 0; i < size; i++) { | 881 | 362 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 362 | typename ToDataType::FieldType>( | 883 | 362 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 362 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 362 | } | 892 | | | 893 | 81 | block.get_by_position(result).column = | 894 | 81 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 81 | return Status::OK(); | 896 | 81 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 69 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 69 | using FromFieldType = typename FromDataType::FieldType; | 835 | 69 | using ToFieldType = typename ToDataType::FieldType; | 836 | 69 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 69 | const auto* col_from = | 838 | 69 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 69 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 69 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 69 | UInt32 from_scale = 0; | 846 | | | 847 | 69 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 69 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 69 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 69 | ToDataType::check_type_precision(to_precision); | 851 | 69 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 69 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 69 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 69 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 69 | bool narrow_integral = | 857 | 69 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 69 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 69 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 69 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 69 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 69 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 69 | const auto& vec_from = col_from->get_data(); | 867 | 69 | const auto* vec_from_data = vec_from.data(); | 868 | 69 | auto& vec_to = col_to->get_data(); | 869 | 69 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 69 | CastParameters params; | 872 | 69 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 69 | size_t size = vec_from.size(); | 874 | | | 875 | 69 | typename ToFieldType::NativeType scale_multiplier = | 876 | 69 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 69 | typename ToFieldType::NativeType max_result = | 878 | 69 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 69 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 475 | for (size_t i = 0; i < size; i++) { | 881 | 406 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 406 | typename ToDataType::FieldType>( | 883 | 406 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 406 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 406 | } | 892 | | | 893 | 69 | block.get_by_position(result).column = | 894 | 69 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 69 | return Status::OK(); | 896 | 69 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 18 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 18 | using FromFieldType = typename FromDataType::FieldType; | 835 | 18 | using ToFieldType = typename ToDataType::FieldType; | 836 | 18 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 18 | const auto* col_from = | 838 | 18 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 18 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 18 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 18 | UInt32 from_scale = 0; | 846 | | | 847 | 18 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 18 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 18 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 18 | ToDataType::check_type_precision(to_precision); | 851 | 18 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 18 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 18 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 18 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 18 | bool narrow_integral = | 857 | 18 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 18 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 18 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 18 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 18 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 18 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 18 | const auto& vec_from = col_from->get_data(); | 867 | 18 | const auto* vec_from_data = vec_from.data(); | 868 | 18 | auto& vec_to = col_to->get_data(); | 869 | 18 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 18 | CastParameters params; | 872 | 18 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 18 | size_t size = vec_from.size(); | 874 | | | 875 | 18 | typename ToFieldType::NativeType scale_multiplier = | 876 | 18 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 18 | typename ToFieldType::NativeType max_result = | 878 | 18 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 18 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 18 | for (size_t i = 0; i < size; i++) { | 881 | 18 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 18 | typename ToDataType::FieldType>( | 883 | 18 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 18 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 0 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 18 | return params.status; | 889 | 18 | } | 890 | 18 | } | 891 | 18 | } | 892 | | | 893 | 0 | block.get_by_position(result).column = | 894 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 0 | return Status::OK(); | 896 | 18 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_15DataTypeDecimalILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 833 | 81 | const NullMap::value_type* null_map = nullptr) const override { | 834 | 81 | using FromFieldType = typename FromDataType::FieldType; | 835 | 81 | using ToFieldType = typename ToDataType::FieldType; | 836 | 81 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 837 | 81 | const auto* col_from = | 838 | 81 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 839 | 81 | if (!col_from) { | 840 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 841 | 0 | named_from.column->get_name()); | 842 | 0 | } | 843 | | | 844 | 81 | UInt32 from_precision = NumberTraits::max_ascii_len<FromFieldType>(); | 845 | 81 | UInt32 from_scale = 0; | 846 | | | 847 | 81 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 848 | 81 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 849 | 81 | UInt32 to_precision = to_decimal_type.get_precision(); | 850 | 81 | ToDataType::check_type_precision(to_precision); | 851 | 81 | UInt32 to_scale = to_decimal_type.get_scale(); | 852 | 81 | ToDataType::check_type_scale(to_scale); | 853 | | | 854 | 81 | auto from_max_int_digit_count = from_precision - from_scale; | 855 | 81 | auto to_max_int_digit_count = to_precision - to_scale; | 856 | 81 | bool narrow_integral = | 857 | 81 | (to_max_int_digit_count < from_max_int_digit_count) || | 858 | 81 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 859 | | // only in non-strict mode and may overflow, we set nullable | 860 | 81 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 861 | | | 862 | 81 | ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(input_rows_count, 0); | 863 | 81 | NullMap::value_type* null_map_data = col_null_map_to->get_data().data(); | 864 | | | 865 | 81 | auto col_to = ToDataType::ColumnType::create(input_rows_count, to_scale); | 866 | 81 | const auto& vec_from = col_from->get_data(); | 867 | 81 | const auto* vec_from_data = vec_from.data(); | 868 | 81 | auto& vec_to = col_to->get_data(); | 869 | 81 | auto* vec_to_data = vec_to.data(); | 870 | | | 871 | 81 | CastParameters params; | 872 | 81 | params.is_strict = (CastMode == CastModeType::StrictMode); | 873 | 81 | size_t size = vec_from.size(); | 874 | | | 875 | 81 | typename ToFieldType::NativeType scale_multiplier = | 876 | 81 | DataTypeDecimal<ToFieldType::PType>::get_scale_multiplier(to_scale); | 877 | 81 | typename ToFieldType::NativeType max_result = | 878 | 81 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 879 | 81 | typename ToFieldType::NativeType min_result = -max_result; | 880 | 499 | for (size_t i = 0; i < size; i++) { | 881 | 418 | if (!CastToDecimal::_from_float<typename FromDataType::FieldType, | 882 | 418 | typename ToDataType::FieldType>( | 883 | 418 | vec_from_data[i], vec_to_data[i], to_precision, to_scale, scale_multiplier, | 884 | 418 | min_result, max_result, params)) { | 885 | 18 | if (set_nullable) { | 886 | 18 | null_map_data[i] = 1; | 887 | 18 | } else { | 888 | 0 | return params.status; | 889 | 0 | } | 890 | 18 | } | 891 | 418 | } | 892 | | | 893 | 81 | block.get_by_position(result).column = | 894 | 81 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 895 | 81 | return Status::OK(); | 896 | 81 | } |
|
897 | | }; |
898 | | |
899 | | // cast decimalv3 types to decimalv2 types |
900 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
901 | | requires(IsDataTypeDecimalV3<ToDataType> && IsDataTypeDecimalV2<ToDataType>) |
902 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
903 | | public: |
904 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
905 | | uint32_t result, size_t input_rows_count, |
906 | | const NullMap::value_type* null_map = nullptr) const override { |
907 | | return Status::RuntimeError( |
908 | | "not support {} ", |
909 | | cast_mode_type_to_string(CastMode, block.get_by_position(arguments[0]).type, |
910 | | block.get_by_position(result).type)); |
911 | | } |
912 | | }; |
913 | | |
914 | | // cast decimalv2 types to decimalv3 types |
915 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
916 | | requires(IsDataTypeDecimalV2<FromDataType> && IsDataTypeDecimalV3<ToDataType>) |
917 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
918 | | public: |
919 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
920 | | uint32_t result, size_t input_rows_count, |
921 | 608 | const NullMap::value_type* null_map = nullptr) const override { |
922 | 608 | using FromFieldType = typename FromDataType::FieldType; |
923 | 608 | using ToFieldType = typename ToDataType::FieldType; |
924 | 608 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); |
925 | 608 | const auto* col_from = |
926 | 608 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); |
927 | 608 | if (!col_from) { |
928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", |
929 | 0 | named_from.column->get_name()); |
930 | 0 | } |
931 | | |
932 | 608 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); |
933 | 608 | UInt32 from_precision = from_decimal_type.get_precision(); |
934 | 608 | UInt32 from_scale = from_decimal_type.get_scale(); |
935 | 608 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); |
936 | 608 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); |
937 | | |
938 | 608 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); |
939 | 608 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); |
940 | 608 | UInt32 to_precision = to_decimal_type.get_precision(); |
941 | 608 | ToDataType::check_type_precision(to_precision); |
942 | 608 | UInt32 to_scale = to_decimal_type.get_scale(); |
943 | 608 | ToDataType::check_type_scale(to_scale); |
944 | | |
945 | 608 | auto from_max_int_digit_count = from_original_precision - from_original_scale; |
946 | 608 | auto to_max_int_digit_count = to_precision - to_scale; |
947 | 608 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || |
948 | 608 | (to_max_int_digit_count == from_max_int_digit_count && |
949 | 216 | to_scale < from_original_scale); |
950 | | // only in non-strict mode and may overflow, we set nullable |
951 | 608 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; |
952 | | |
953 | 608 | size_t size = col_from->size(); |
954 | 608 | ColumnUInt8::MutablePtr col_null_map_to; |
955 | 608 | NullMap::value_type* null_map_data = nullptr; |
956 | 608 | if (narrow_integral) { |
957 | 410 | col_null_map_to = ColumnUInt8::create(size, 0); |
958 | 410 | null_map_data = col_null_map_to->get_data().data(); |
959 | 410 | } |
960 | 608 | CastParameters params; |
961 | 608 | params.is_strict = (CastMode == CastModeType::StrictMode); |
962 | 608 | auto col_to = ToDataType::ColumnType::create(size, to_scale); |
963 | 608 | const auto& vec_from = col_from->get_data(); |
964 | 608 | const auto* vec_from_data = vec_from.data(); |
965 | 608 | auto& vec_to = col_to->get_data(); |
966 | 608 | auto* vec_to_data = vec_to.data(); |
967 | | |
968 | 608 | using MaxFieldType = |
969 | 608 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && |
970 | 608 | (std::is_same_v<ToFieldType, Decimal128V3> || |
971 | 608 | std::is_same_v<FromFieldType, Decimal128V3>), |
972 | 608 | Decimal128V3, |
973 | 608 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), |
974 | 608 | FromFieldType, ToFieldType>>; |
975 | 608 | using MaxNativeType = typename MaxFieldType::NativeType; |
976 | | |
977 | 608 | constexpr UInt32 to_max_digits = |
978 | 608 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); |
979 | 608 | bool multiply_may_overflow = false; |
980 | 608 | if (to_scale > from_scale) { |
981 | 186 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; |
982 | 186 | } |
983 | | |
984 | 608 | typename ToFieldType::NativeType max_result = |
985 | 608 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); |
986 | 608 | typename ToFieldType::NativeType min_result = -max_result; |
987 | | |
988 | 608 | MaxNativeType multiplier {}; |
989 | 608 | if (from_scale < to_scale) { |
990 | 186 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - |
991 | 186 | from_scale); |
992 | 422 | } else if (from_scale > to_scale) { |
993 | 388 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - |
994 | 388 | to_scale); |
995 | 388 | } |
996 | 608 | RETURN_IF_ERROR(std::visit( |
997 | 608 | [&](auto multiply_may_overflow, auto narrow_integral) { |
998 | 608 | for (size_t i = 0; i < size; i++) { |
999 | 608 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, |
1000 | 608 | multiply_may_overflow, narrow_integral>( |
1001 | 608 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], |
1002 | 608 | to_precision, to_scale, min_result, max_result, multiplier, |
1003 | 608 | params)) { |
1004 | 608 | if (set_nullable) { |
1005 | 608 | null_map_data[i] = 1; |
1006 | 608 | } else { |
1007 | 608 | return params.status; |
1008 | 608 | } |
1009 | 608 | } |
1010 | 608 | } |
1011 | 608 | return Status::OK(); |
1012 | 608 | }, |
1013 | 608 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); |
1014 | 387 | if (narrow_integral) { |
1015 | 189 | block.get_by_position(result).column = |
1016 | 189 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); |
1017 | 198 | } else { |
1018 | 198 | block.get_by_position(result).column = std::move(col_to); |
1019 | 198 | } |
1020 | 387 | return Status::OK(); |
1021 | 608 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 87 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 87 | using FromFieldType = typename FromDataType::FieldType; | 923 | 87 | using ToFieldType = typename ToDataType::FieldType; | 924 | 87 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 87 | const auto* col_from = | 926 | 87 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 87 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 87 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 87 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 87 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 87 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 87 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 87 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 87 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 87 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 87 | ToDataType::check_type_precision(to_precision); | 942 | 87 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 87 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 87 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 87 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 87 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 87 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 0 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 87 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 87 | size_t size = col_from->size(); | 954 | 87 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 87 | NullMap::value_type* null_map_data = nullptr; | 956 | 87 | if (narrow_integral) { | 957 | 87 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 87 | null_map_data = col_null_map_to->get_data().data(); | 959 | 87 | } | 960 | 87 | CastParameters params; | 961 | 87 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 87 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 87 | const auto& vec_from = col_from->get_data(); | 964 | 87 | const auto* vec_from_data = vec_from.data(); | 965 | 87 | auto& vec_to = col_to->get_data(); | 966 | 87 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 87 | using MaxFieldType = | 969 | 87 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 87 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 87 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 87 | Decimal128V3, | 973 | 87 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 87 | FromFieldType, ToFieldType>>; | 975 | 87 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 87 | constexpr UInt32 to_max_digits = | 978 | 87 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 87 | bool multiply_may_overflow = false; | 980 | 87 | if (to_scale > from_scale) { | 981 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 0 | } | 983 | | | 984 | 87 | typename ToFieldType::NativeType max_result = | 985 | 87 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 87 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 87 | MaxNativeType multiplier {}; | 989 | 87 | if (from_scale < to_scale) { | 990 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 0 | from_scale); | 992 | 87 | } else if (from_scale > to_scale) { | 993 | 78 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 78 | to_scale); | 995 | 78 | } | 996 | 87 | RETURN_IF_ERROR(std::visit( | 997 | 87 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 87 | for (size_t i = 0; i < size; i++) { | 999 | 87 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 87 | multiply_may_overflow, narrow_integral>( | 1001 | 87 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 87 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 87 | params)) { | 1004 | 87 | if (set_nullable) { | 1005 | 87 | null_map_data[i] = 1; | 1006 | 87 | } else { | 1007 | 87 | return params.status; | 1008 | 87 | } | 1009 | 87 | } | 1010 | 87 | } | 1011 | 87 | return Status::OK(); | 1012 | 87 | }, | 1013 | 87 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 0 | if (narrow_integral) { | 1015 | 0 | block.get_by_position(result).column = | 1016 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 0 | } else { | 1018 | 0 | block.get_by_position(result).column = std::move(col_to); | 1019 | 0 | } | 1020 | 0 | return Status::OK(); | 1021 | 87 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 74 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 74 | using FromFieldType = typename FromDataType::FieldType; | 923 | 74 | using ToFieldType = typename ToDataType::FieldType; | 924 | 74 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 74 | const auto* col_from = | 926 | 74 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 74 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 74 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 74 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 74 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 74 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 74 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 74 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 74 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 74 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 74 | ToDataType::check_type_precision(to_precision); | 942 | 74 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 74 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 74 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 74 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 74 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 74 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 18 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 74 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 74 | size_t size = col_from->size(); | 954 | 74 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 74 | NullMap::value_type* null_map_data = nullptr; | 956 | 74 | if (narrow_integral) { | 957 | 56 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 56 | null_map_data = col_null_map_to->get_data().data(); | 959 | 56 | } | 960 | 74 | CastParameters params; | 961 | 74 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 74 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 74 | const auto& vec_from = col_from->get_data(); | 964 | 74 | const auto* vec_from_data = vec_from.data(); | 965 | 74 | auto& vec_to = col_to->get_data(); | 966 | 74 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 74 | using MaxFieldType = | 969 | 74 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 74 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 74 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 74 | Decimal128V3, | 973 | 74 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 74 | FromFieldType, ToFieldType>>; | 975 | 74 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 74 | constexpr UInt32 to_max_digits = | 978 | 74 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 74 | bool multiply_may_overflow = false; | 980 | 74 | if (to_scale > from_scale) { | 981 | 0 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 0 | } | 983 | | | 984 | 74 | typename ToFieldType::NativeType max_result = | 985 | 74 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 74 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 74 | MaxNativeType multiplier {}; | 989 | 74 | if (from_scale < to_scale) { | 990 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 0 | from_scale); | 992 | 74 | } else if (from_scale > to_scale) { | 993 | 67 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 67 | to_scale); | 995 | 67 | } | 996 | 74 | RETURN_IF_ERROR(std::visit( | 997 | 74 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 74 | for (size_t i = 0; i < size; i++) { | 999 | 74 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 74 | multiply_may_overflow, narrow_integral>( | 1001 | 74 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 74 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 74 | params)) { | 1004 | 74 | if (set_nullable) { | 1005 | 74 | null_map_data[i] = 1; | 1006 | 74 | } else { | 1007 | 74 | return params.status; | 1008 | 74 | } | 1009 | 74 | } | 1010 | 74 | } | 1011 | 74 | return Status::OK(); | 1012 | 74 | }, | 1013 | 74 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 74 | if (narrow_integral) { | 1015 | 56 | block.get_by_position(result).column = | 1016 | 56 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 56 | } else { | 1018 | 18 | block.get_by_position(result).column = std::move(col_to); | 1019 | 18 | } | 1020 | 74 | return Status::OK(); | 1021 | 74 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 72 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 72 | using FromFieldType = typename FromDataType::FieldType; | 923 | 72 | using ToFieldType = typename ToDataType::FieldType; | 924 | 72 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 72 | const auto* col_from = | 926 | 72 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 72 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 72 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 72 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 72 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 72 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 72 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 72 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 72 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 72 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 72 | ToDataType::check_type_precision(to_precision); | 942 | 72 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 72 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 72 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 72 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 72 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 72 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 2 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 72 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 72 | size_t size = col_from->size(); | 954 | 72 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 72 | NullMap::value_type* null_map_data = nullptr; | 956 | 72 | if (narrow_integral) { | 957 | 72 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 72 | null_map_data = col_null_map_to->get_data().data(); | 959 | 72 | } | 960 | 72 | CastParameters params; | 961 | 72 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 72 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 72 | const auto& vec_from = col_from->get_data(); | 964 | 72 | const auto* vec_from_data = vec_from.data(); | 965 | 72 | auto& vec_to = col_to->get_data(); | 966 | 72 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 72 | using MaxFieldType = | 969 | 72 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 72 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 72 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 72 | Decimal128V3, | 973 | 72 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 72 | FromFieldType, ToFieldType>>; | 975 | 72 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 72 | constexpr UInt32 to_max_digits = | 978 | 72 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 72 | bool multiply_may_overflow = false; | 980 | 72 | if (to_scale > from_scale) { | 981 | 24 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 24 | } | 983 | | | 984 | 72 | typename ToFieldType::NativeType max_result = | 985 | 72 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 72 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 72 | MaxNativeType multiplier {}; | 989 | 72 | if (from_scale < to_scale) { | 990 | 24 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 24 | from_scale); | 992 | 48 | } else if (from_scale > to_scale) { | 993 | 42 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 42 | to_scale); | 995 | 42 | } | 996 | 72 | RETURN_IF_ERROR(std::visit( | 997 | 72 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 72 | for (size_t i = 0; i < size; i++) { | 999 | 72 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 72 | multiply_may_overflow, narrow_integral>( | 1001 | 72 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 72 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 72 | params)) { | 1004 | 72 | if (set_nullable) { | 1005 | 72 | null_map_data[i] = 1; | 1006 | 72 | } else { | 1007 | 72 | return params.status; | 1008 | 72 | } | 1009 | 72 | } | 1010 | 72 | } | 1011 | 72 | return Status::OK(); | 1012 | 72 | }, | 1013 | 72 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 0 | if (narrow_integral) { | 1015 | 0 | block.get_by_position(result).column = | 1016 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 0 | } else { | 1018 | 0 | block.get_by_position(result).column = std::move(col_to); | 1019 | 0 | } | 1020 | 0 | return Status::OK(); | 1021 | 72 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 108 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 108 | using FromFieldType = typename FromDataType::FieldType; | 923 | 108 | using ToFieldType = typename ToDataType::FieldType; | 924 | 108 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 108 | const auto* col_from = | 926 | 108 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 108 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 108 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 108 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 108 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 108 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 108 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 108 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 108 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 108 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 108 | ToDataType::check_type_precision(to_precision); | 942 | 108 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 108 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 108 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 108 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 108 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 108 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 45 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 108 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 108 | size_t size = col_from->size(); | 954 | 108 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 108 | NullMap::value_type* null_map_data = nullptr; | 956 | 108 | if (narrow_integral) { | 957 | 70 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 70 | null_map_data = col_null_map_to->get_data().data(); | 959 | 70 | } | 960 | 108 | CastParameters params; | 961 | 108 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 108 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 108 | const auto& vec_from = col_from->get_data(); | 964 | 108 | const auto* vec_from_data = vec_from.data(); | 965 | 108 | auto& vec_to = col_to->get_data(); | 966 | 108 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 108 | using MaxFieldType = | 969 | 108 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 108 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 108 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 108 | Decimal128V3, | 973 | 108 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 108 | FromFieldType, ToFieldType>>; | 975 | 108 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 108 | constexpr UInt32 to_max_digits = | 978 | 108 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 108 | bool multiply_may_overflow = false; | 980 | 108 | if (to_scale > from_scale) { | 981 | 26 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 26 | } | 983 | | | 984 | 108 | typename ToFieldType::NativeType max_result = | 985 | 108 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 108 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 108 | MaxNativeType multiplier {}; | 989 | 108 | if (from_scale < to_scale) { | 990 | 26 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 26 | from_scale); | 992 | 82 | } else if (from_scale > to_scale) { | 993 | 70 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 70 | to_scale); | 995 | 70 | } | 996 | 108 | RETURN_IF_ERROR(std::visit( | 997 | 108 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 108 | for (size_t i = 0; i < size; i++) { | 999 | 108 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 108 | multiply_may_overflow, narrow_integral>( | 1001 | 108 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 108 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 108 | params)) { | 1004 | 108 | if (set_nullable) { | 1005 | 108 | null_map_data[i] = 1; | 1006 | 108 | } else { | 1007 | 108 | return params.status; | 1008 | 108 | } | 1009 | 108 | } | 1010 | 108 | } | 1011 | 108 | return Status::OK(); | 1012 | 108 | }, | 1013 | 108 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 108 | if (narrow_integral) { | 1015 | 70 | block.get_by_position(result).column = | 1016 | 70 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 70 | } else { | 1018 | 38 | block.get_by_position(result).column = std::move(col_to); | 1019 | 38 | } | 1020 | 108 | return Status::OK(); | 1021 | 108 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 32 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 32 | using FromFieldType = typename FromDataType::FieldType; | 923 | 32 | using ToFieldType = typename ToDataType::FieldType; | 924 | 32 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 32 | const auto* col_from = | 926 | 32 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 32 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 32 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 32 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 32 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 32 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 32 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 32 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 32 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 32 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 32 | ToDataType::check_type_precision(to_precision); | 942 | 32 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 32 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 32 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 32 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 32 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 32 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 2 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 32 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 32 | size_t size = col_from->size(); | 954 | 32 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 32 | NullMap::value_type* null_map_data = nullptr; | 956 | 32 | if (narrow_integral) { | 957 | 32 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 32 | null_map_data = col_null_map_to->get_data().data(); | 959 | 32 | } | 960 | 32 | CastParameters params; | 961 | 32 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 32 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 32 | const auto& vec_from = col_from->get_data(); | 964 | 32 | const auto* vec_from_data = vec_from.data(); | 965 | 32 | auto& vec_to = col_to->get_data(); | 966 | 32 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 32 | using MaxFieldType = | 969 | 32 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 32 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 32 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 32 | Decimal128V3, | 973 | 32 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 32 | FromFieldType, ToFieldType>>; | 975 | 32 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 32 | constexpr UInt32 to_max_digits = | 978 | 32 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 32 | bool multiply_may_overflow = false; | 980 | 32 | if (to_scale > from_scale) { | 981 | 30 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 30 | } | 983 | | | 984 | 32 | typename ToFieldType::NativeType max_result = | 985 | 32 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 32 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 32 | MaxNativeType multiplier {}; | 989 | 32 | if (from_scale < to_scale) { | 990 | 30 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 30 | from_scale); | 992 | 30 | } else if (from_scale > to_scale) { | 993 | 2 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 2 | to_scale); | 995 | 2 | } | 996 | 32 | RETURN_IF_ERROR(std::visit( | 997 | 32 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 32 | for (size_t i = 0; i < size; i++) { | 999 | 32 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 32 | multiply_may_overflow, narrow_integral>( | 1001 | 32 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 32 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 32 | params)) { | 1004 | 32 | if (set_nullable) { | 1005 | 32 | null_map_data[i] = 1; | 1006 | 32 | } else { | 1007 | 32 | return params.status; | 1008 | 32 | } | 1009 | 32 | } | 1010 | 32 | } | 1011 | 32 | return Status::OK(); | 1012 | 32 | }, | 1013 | 32 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 0 | if (narrow_integral) { | 1015 | 0 | block.get_by_position(result).column = | 1016 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 0 | } else { | 1018 | 0 | block.get_by_position(result).column = std::move(col_to); | 1019 | 0 | } | 1020 | 0 | return Status::OK(); | 1021 | 32 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 103 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 103 | using FromFieldType = typename FromDataType::FieldType; | 923 | 103 | using ToFieldType = typename ToDataType::FieldType; | 924 | 103 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 103 | const auto* col_from = | 926 | 103 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 103 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 103 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 103 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 103 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 103 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 103 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 103 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 103 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 103 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 103 | ToDataType::check_type_precision(to_precision); | 942 | 103 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 103 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 103 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 103 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 103 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 103 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 75 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 103 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 103 | size_t size = col_from->size(); | 954 | 103 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 103 | NullMap::value_type* null_map_data = nullptr; | 956 | 103 | if (narrow_integral) { | 957 | 35 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 35 | null_map_data = col_null_map_to->get_data().data(); | 959 | 35 | } | 960 | 103 | CastParameters params; | 961 | 103 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 103 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 103 | const auto& vec_from = col_from->get_data(); | 964 | 103 | const auto* vec_from_data = vec_from.data(); | 965 | 103 | auto& vec_to = col_to->get_data(); | 966 | 103 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 103 | using MaxFieldType = | 969 | 103 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 103 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 103 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 103 | Decimal128V3, | 973 | 103 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 103 | FromFieldType, ToFieldType>>; | 975 | 103 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 103 | constexpr UInt32 to_max_digits = | 978 | 103 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 103 | bool multiply_may_overflow = false; | 980 | 103 | if (to_scale > from_scale) { | 981 | 38 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 38 | } | 983 | | | 984 | 103 | typename ToFieldType::NativeType max_result = | 985 | 103 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 103 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 103 | MaxNativeType multiplier {}; | 989 | 103 | if (from_scale < to_scale) { | 990 | 38 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 38 | from_scale); | 992 | 65 | } else if (from_scale > to_scale) { | 993 | 65 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 65 | to_scale); | 995 | 65 | } | 996 | 103 | RETURN_IF_ERROR(std::visit( | 997 | 103 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 103 | for (size_t i = 0; i < size; i++) { | 999 | 103 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 103 | multiply_may_overflow, narrow_integral>( | 1001 | 103 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 103 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 103 | params)) { | 1004 | 103 | if (set_nullable) { | 1005 | 103 | null_map_data[i] = 1; | 1006 | 103 | } else { | 1007 | 103 | return params.status; | 1008 | 103 | } | 1009 | 103 | } | 1010 | 103 | } | 1011 | 103 | return Status::OK(); | 1012 | 103 | }, | 1013 | 103 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 103 | if (narrow_integral) { | 1015 | 35 | block.get_by_position(result).column = | 1016 | 35 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 68 | } else { | 1018 | 68 | block.get_by_position(result).column = std::move(col_to); | 1019 | 68 | } | 1020 | 103 | return Status::OK(); | 1021 | 103 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 30 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 30 | using FromFieldType = typename FromDataType::FieldType; | 923 | 30 | using ToFieldType = typename ToDataType::FieldType; | 924 | 30 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 30 | const auto* col_from = | 926 | 30 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 30 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 30 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 30 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 30 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 30 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 30 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 30 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 30 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 30 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 30 | ToDataType::check_type_precision(to_precision); | 942 | 30 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 30 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 30 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 30 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 30 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 30 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 0 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 30 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 30 | size_t size = col_from->size(); | 954 | 30 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 30 | NullMap::value_type* null_map_data = nullptr; | 956 | 30 | if (narrow_integral) { | 957 | 30 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 30 | null_map_data = col_null_map_to->get_data().data(); | 959 | 30 | } | 960 | 30 | CastParameters params; | 961 | 30 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 30 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 30 | const auto& vec_from = col_from->get_data(); | 964 | 30 | const auto* vec_from_data = vec_from.data(); | 965 | 30 | auto& vec_to = col_to->get_data(); | 966 | 30 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 30 | using MaxFieldType = | 969 | 30 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 30 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 30 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 30 | Decimal128V3, | 973 | 30 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 30 | FromFieldType, ToFieldType>>; | 975 | 30 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 30 | constexpr UInt32 to_max_digits = | 978 | 30 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 30 | bool multiply_may_overflow = false; | 980 | 30 | if (to_scale > from_scale) { | 981 | 30 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 30 | } | 983 | | | 984 | 30 | typename ToFieldType::NativeType max_result = | 985 | 30 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 30 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 30 | MaxNativeType multiplier {}; | 989 | 30 | if (from_scale < to_scale) { | 990 | 30 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 30 | from_scale); | 992 | 30 | } else if (from_scale > to_scale) { | 993 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 0 | to_scale); | 995 | 0 | } | 996 | 30 | RETURN_IF_ERROR(std::visit( | 997 | 30 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 30 | for (size_t i = 0; i < size; i++) { | 999 | 30 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 30 | multiply_may_overflow, narrow_integral>( | 1001 | 30 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 30 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 30 | params)) { | 1004 | 30 | if (set_nullable) { | 1005 | 30 | null_map_data[i] = 1; | 1006 | 30 | } else { | 1007 | 30 | return params.status; | 1008 | 30 | } | 1009 | 30 | } | 1010 | 30 | } | 1011 | 30 | return Status::OK(); | 1012 | 30 | }, | 1013 | 30 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 0 | if (narrow_integral) { | 1015 | 0 | block.get_by_position(result).column = | 1016 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 0 | } else { | 1018 | 0 | block.get_by_position(result).column = std::move(col_to); | 1019 | 0 | } | 1020 | 0 | return Status::OK(); | 1021 | 30 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 921 | 102 | const NullMap::value_type* null_map = nullptr) const override { | 922 | 102 | using FromFieldType = typename FromDataType::FieldType; | 923 | 102 | using ToFieldType = typename ToDataType::FieldType; | 924 | 102 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 925 | 102 | const auto* col_from = | 926 | 102 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 927 | 102 | if (!col_from) { | 928 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 929 | 0 | named_from.column->get_name()); | 930 | 0 | } | 931 | | | 932 | 102 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 933 | 102 | UInt32 from_precision = from_decimal_type.get_precision(); | 934 | 102 | UInt32 from_scale = from_decimal_type.get_scale(); | 935 | 102 | UInt32 from_original_precision = from_decimal_type.get_original_precision(); | 936 | 102 | UInt32 from_original_scale = from_decimal_type.get_original_scale(); | 937 | | | 938 | 102 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 939 | 102 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 940 | 102 | UInt32 to_precision = to_decimal_type.get_precision(); | 941 | 102 | ToDataType::check_type_precision(to_precision); | 942 | 102 | UInt32 to_scale = to_decimal_type.get_scale(); | 943 | 102 | ToDataType::check_type_scale(to_scale); | 944 | | | 945 | 102 | auto from_max_int_digit_count = from_original_precision - from_original_scale; | 946 | 102 | auto to_max_int_digit_count = to_precision - to_scale; | 947 | 102 | bool narrow_integral = (to_max_int_digit_count < from_max_int_digit_count) || | 948 | 102 | (to_max_int_digit_count == from_max_int_digit_count && | 949 | 74 | to_scale < from_original_scale); | 950 | | // only in non-strict mode and may overflow, we set nullable | 951 | 102 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 952 | | | 953 | 102 | size_t size = col_from->size(); | 954 | 102 | ColumnUInt8::MutablePtr col_null_map_to; | 955 | 102 | NullMap::value_type* null_map_data = nullptr; | 956 | 102 | if (narrow_integral) { | 957 | 28 | col_null_map_to = ColumnUInt8::create(size, 0); | 958 | 28 | null_map_data = col_null_map_to->get_data().data(); | 959 | 28 | } | 960 | 102 | CastParameters params; | 961 | 102 | params.is_strict = (CastMode == CastModeType::StrictMode); | 962 | 102 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 963 | 102 | const auto& vec_from = col_from->get_data(); | 964 | 102 | const auto* vec_from_data = vec_from.data(); | 965 | 102 | auto& vec_to = col_to->get_data(); | 966 | 102 | auto* vec_to_data = vec_to.data(); | 967 | | | 968 | 102 | using MaxFieldType = | 969 | 102 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 970 | 102 | (std::is_same_v<ToFieldType, Decimal128V3> || | 971 | 102 | std::is_same_v<FromFieldType, Decimal128V3>), | 972 | 102 | Decimal128V3, | 973 | 102 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 974 | 102 | FromFieldType, ToFieldType>>; | 975 | 102 | using MaxNativeType = typename MaxFieldType::NativeType; | 976 | | | 977 | 102 | constexpr UInt32 to_max_digits = | 978 | 102 | NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 979 | 102 | bool multiply_may_overflow = false; | 980 | 102 | if (to_scale > from_scale) { | 981 | 38 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 982 | 38 | } | 983 | | | 984 | 102 | typename ToFieldType::NativeType max_result = | 985 | 102 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 986 | 102 | typename ToFieldType::NativeType min_result = -max_result; | 987 | | | 988 | 102 | MaxNativeType multiplier {}; | 989 | 102 | if (from_scale < to_scale) { | 990 | 38 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 991 | 38 | from_scale); | 992 | 64 | } else if (from_scale > to_scale) { | 993 | 64 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 994 | 64 | to_scale); | 995 | 64 | } | 996 | 102 | RETURN_IF_ERROR(std::visit( | 997 | 102 | [&](auto multiply_may_overflow, auto narrow_integral) { | 998 | 102 | for (size_t i = 0; i < size; i++) { | 999 | 102 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1000 | 102 | multiply_may_overflow, narrow_integral>( | 1001 | 102 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1002 | 102 | to_precision, to_scale, min_result, max_result, multiplier, | 1003 | 102 | params)) { | 1004 | 102 | if (set_nullable) { | 1005 | 102 | null_map_data[i] = 1; | 1006 | 102 | } else { | 1007 | 102 | return params.status; | 1008 | 102 | } | 1009 | 102 | } | 1010 | 102 | } | 1011 | 102 | return Status::OK(); | 1012 | 102 | }, | 1013 | 102 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1014 | 102 | if (narrow_integral) { | 1015 | 28 | block.get_by_position(result).column = | 1016 | 28 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1017 | 74 | } else { | 1018 | 74 | block.get_by_position(result).column = std::move(col_to); | 1019 | 74 | } | 1020 | 102 | return Status::OK(); | 1021 | 102 | } |
|
1022 | | }; |
1023 | | |
1024 | | // cast between decimalv3 types |
1025 | | template <CastModeType CastMode, typename FromDataType, typename ToDataType> |
1026 | | requires(IsDataTypeDecimalV3<ToDataType> && IsDataTypeDecimalV3<FromDataType>) |
1027 | | class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase { |
1028 | | public: |
1029 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
1030 | | uint32_t result, size_t input_rows_count, |
1031 | 4.29k | const NullMap::value_type* null_map = nullptr) const override { |
1032 | 4.29k | using FromFieldType = typename FromDataType::FieldType; |
1033 | 4.29k | using ToFieldType = typename ToDataType::FieldType; |
1034 | 4.29k | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); |
1035 | 4.29k | const auto* col_from = |
1036 | 4.29k | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); |
1037 | 4.29k | if (!col_from) { |
1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", |
1039 | 0 | named_from.column->get_name()); |
1040 | 0 | } |
1041 | | |
1042 | 4.29k | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); |
1043 | 4.29k | UInt32 from_precision = from_decimal_type.get_precision(); |
1044 | 4.29k | UInt32 from_scale = from_decimal_type.get_scale(); |
1045 | | |
1046 | 4.29k | const ColumnWithTypeAndName& named_to = block.get_by_position(result); |
1047 | 4.29k | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); |
1048 | 4.29k | UInt32 to_precision = to_decimal_type.get_precision(); |
1049 | 4.29k | ToDataType::check_type_precision(to_precision); |
1050 | 4.29k | UInt32 to_scale = to_decimal_type.get_scale(); |
1051 | 4.29k | ToDataType::check_type_scale(to_scale); |
1052 | | |
1053 | 4.29k | auto from_max_int_digit_count = from_precision - from_scale; |
1054 | 4.29k | auto to_max_int_digit_count = to_precision - to_scale; |
1055 | 4.29k | bool narrow_integral = |
1056 | 4.29k | (to_max_int_digit_count < from_max_int_digit_count) || |
1057 | 4.29k | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); |
1058 | | // only in non-strict mode and may overflow, we set nullable |
1059 | 4.29k | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; |
1060 | | |
1061 | 4.29k | size_t size = col_from->size(); |
1062 | 4.29k | ColumnUInt8::MutablePtr col_null_map_to; |
1063 | 4.29k | NullMap::value_type* null_map_data = nullptr; |
1064 | 4.29k | if (narrow_integral) { |
1065 | 3.12k | col_null_map_to = ColumnUInt8::create(size, 0); |
1066 | 3.12k | null_map_data = col_null_map_to->get_data().data(); |
1067 | 3.12k | } |
1068 | 4.29k | CastParameters params; |
1069 | 4.29k | params.is_strict = (CastMode == CastModeType::StrictMode); |
1070 | 4.29k | auto col_to = ToDataType::ColumnType::create(size, to_scale); |
1071 | 4.29k | const auto& vec_from = col_from->get_data(); |
1072 | 4.29k | const auto* vec_from_data = vec_from.data(); |
1073 | 4.29k | auto& vec_to = col_to->get_data(); |
1074 | 4.29k | auto* vec_to_data = vec_to.data(); |
1075 | | |
1076 | 4.29k | using MaxFieldType = |
1077 | 4.29k | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && |
1078 | 4.29k | (std::is_same_v<ToFieldType, Decimal128V3> || |
1079 | 4.29k | std::is_same_v<FromFieldType, Decimal128V3>), |
1080 | 4.29k | Decimal128V3, |
1081 | 4.29k | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), |
1082 | 4.29k | FromFieldType, ToFieldType>>; |
1083 | 4.29k | using MaxNativeType = typename MaxFieldType::NativeType; |
1084 | | |
1085 | 4.29k | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); |
1086 | 4.29k | bool multiply_may_overflow = false; |
1087 | 4.29k | if (to_scale > from_scale) { |
1088 | 1.96k | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; |
1089 | 1.96k | } |
1090 | | |
1091 | 4.29k | typename ToFieldType::NativeType max_result = |
1092 | 4.29k | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); |
1093 | 4.29k | typename ToFieldType::NativeType min_result = -max_result; |
1094 | | |
1095 | 4.29k | MaxNativeType multiplier {}; |
1096 | 4.29k | if (from_scale < to_scale) { |
1097 | 1.96k | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - |
1098 | 1.96k | from_scale); |
1099 | 2.33k | } else if (from_scale > to_scale) { |
1100 | 1.52k | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - |
1101 | 1.52k | to_scale); |
1102 | 1.52k | } |
1103 | 4.29k | RETURN_IF_ERROR(std::visit( |
1104 | 4.29k | [&](auto multiply_may_overflow, auto narrow_integral) { |
1105 | 4.29k | for (size_t i = 0; i < size; i++) { |
1106 | 4.29k | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, |
1107 | 4.29k | multiply_may_overflow, narrow_integral>( |
1108 | 4.29k | vec_from_data[i], from_precision, from_scale, vec_to_data[i], |
1109 | 4.29k | to_precision, to_scale, min_result, max_result, multiplier, |
1110 | 4.29k | params)) { |
1111 | 4.29k | if (set_nullable) { |
1112 | 4.29k | null_map_data[i] = 1; |
1113 | 4.29k | } else { |
1114 | 4.29k | return params.status; |
1115 | 4.29k | } |
1116 | 4.29k | } |
1117 | 4.29k | } |
1118 | 4.29k | return Status::OK(); |
1119 | 4.29k | }, |
1120 | 4.29k | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); |
1121 | 2.79k | if (narrow_integral) { |
1122 | 1.62k | block.get_by_position(result).column = |
1123 | 1.62k | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); |
1124 | 1.62k | } else { |
1125 | 1.17k | block.get_by_position(result).column = std::move(col_to); |
1126 | 1.17k | } |
1127 | 2.79k | return Status::OK(); |
1128 | 4.29k | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 64 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 64 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 64 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 64 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 64 | const auto* col_from = | 1036 | 64 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 64 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 64 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 64 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 64 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 64 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 64 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 64 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 64 | ToDataType::check_type_precision(to_precision); | 1050 | 64 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 64 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 64 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 64 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 64 | bool narrow_integral = | 1056 | 64 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 64 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 64 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 64 | size_t size = col_from->size(); | 1062 | 64 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 64 | NullMap::value_type* null_map_data = nullptr; | 1064 | 64 | if (narrow_integral) { | 1065 | 64 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 64 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 64 | } | 1068 | 64 | CastParameters params; | 1069 | 64 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 64 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 64 | const auto& vec_from = col_from->get_data(); | 1072 | 64 | const auto* vec_from_data = vec_from.data(); | 1073 | 64 | auto& vec_to = col_to->get_data(); | 1074 | 64 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 64 | using MaxFieldType = | 1077 | 64 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 64 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 64 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 64 | Decimal128V3, | 1081 | 64 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 64 | FromFieldType, ToFieldType>>; | 1083 | 64 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 64 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 64 | bool multiply_may_overflow = false; | 1087 | 64 | if (to_scale > from_scale) { | 1088 | 27 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 27 | } | 1090 | | | 1091 | 64 | typename ToFieldType::NativeType max_result = | 1092 | 64 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 64 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 64 | MaxNativeType multiplier {}; | 1096 | 64 | if (from_scale < to_scale) { | 1097 | 27 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 27 | from_scale); | 1099 | 37 | } else if (from_scale > to_scale) { | 1100 | 31 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 31 | to_scale); | 1102 | 31 | } | 1103 | 64 | RETURN_IF_ERROR(std::visit( | 1104 | 64 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 64 | for (size_t i = 0; i < size; i++) { | 1106 | 64 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 64 | multiply_may_overflow, narrow_integral>( | 1108 | 64 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 64 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 64 | params)) { | 1111 | 64 | if (set_nullable) { | 1112 | 64 | null_map_data[i] = 1; | 1113 | 64 | } else { | 1114 | 64 | return params.status; | 1115 | 64 | } | 1116 | 64 | } | 1117 | 64 | } | 1118 | 64 | return Status::OK(); | 1119 | 64 | }, | 1120 | 64 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 7 | if (narrow_integral) { | 1122 | 7 | block.get_by_position(result).column = | 1123 | 7 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 7 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 7 | return Status::OK(); | 1128 | 64 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 77 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 77 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 77 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 77 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 77 | const auto* col_from = | 1036 | 77 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 77 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 77 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 77 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 77 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 77 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 77 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 77 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 77 | ToDataType::check_type_precision(to_precision); | 1050 | 77 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 77 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 77 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 77 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 77 | bool narrow_integral = | 1056 | 77 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 77 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 77 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 77 | size_t size = col_from->size(); | 1062 | 77 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 77 | NullMap::value_type* null_map_data = nullptr; | 1064 | 77 | if (narrow_integral) { | 1065 | 47 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 47 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 47 | } | 1068 | 77 | CastParameters params; | 1069 | 77 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 77 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 77 | const auto& vec_from = col_from->get_data(); | 1072 | 77 | const auto* vec_from_data = vec_from.data(); | 1073 | 77 | auto& vec_to = col_to->get_data(); | 1074 | 77 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 77 | using MaxFieldType = | 1077 | 77 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 77 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 77 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 77 | Decimal128V3, | 1081 | 77 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 77 | FromFieldType, ToFieldType>>; | 1083 | 77 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 77 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 77 | bool multiply_may_overflow = false; | 1087 | 77 | if (to_scale > from_scale) { | 1088 | 35 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 35 | } | 1090 | | | 1091 | 77 | typename ToFieldType::NativeType max_result = | 1092 | 77 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 77 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 77 | MaxNativeType multiplier {}; | 1096 | 77 | if (from_scale < to_scale) { | 1097 | 35 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 35 | from_scale); | 1099 | 42 | } else if (from_scale > to_scale) { | 1100 | 32 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 32 | to_scale); | 1102 | 32 | } | 1103 | 77 | RETURN_IF_ERROR(std::visit( | 1104 | 77 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 77 | for (size_t i = 0; i < size; i++) { | 1106 | 77 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 77 | multiply_may_overflow, narrow_integral>( | 1108 | 77 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 77 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 77 | params)) { | 1111 | 77 | if (set_nullable) { | 1112 | 77 | null_map_data[i] = 1; | 1113 | 77 | } else { | 1114 | 77 | return params.status; | 1115 | 77 | } | 1116 | 77 | } | 1117 | 77 | } | 1118 | 77 | return Status::OK(); | 1119 | 77 | }, | 1120 | 77 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 77 | if (narrow_integral) { | 1122 | 47 | block.get_by_position(result).column = | 1123 | 47 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 47 | } else { | 1125 | 30 | block.get_by_position(result).column = std::move(col_to); | 1126 | 30 | } | 1127 | 77 | return Status::OK(); | 1128 | 77 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 129 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 129 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 129 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 129 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 129 | const auto* col_from = | 1036 | 129 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 129 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 129 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 129 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 129 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 129 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 129 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 129 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 129 | ToDataType::check_type_precision(to_precision); | 1050 | 129 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 129 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 129 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 129 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 129 | bool narrow_integral = | 1056 | 129 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 129 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 129 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 129 | size_t size = col_from->size(); | 1062 | 129 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 129 | NullMap::value_type* null_map_data = nullptr; | 1064 | 129 | if (narrow_integral) { | 1065 | 129 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 129 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 129 | } | 1068 | 129 | CastParameters params; | 1069 | 129 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 129 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 129 | const auto& vec_from = col_from->get_data(); | 1072 | 129 | const auto* vec_from_data = vec_from.data(); | 1073 | 129 | auto& vec_to = col_to->get_data(); | 1074 | 129 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 129 | using MaxFieldType = | 1077 | 129 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 129 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 129 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 129 | Decimal128V3, | 1081 | 129 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 129 | FromFieldType, ToFieldType>>; | 1083 | 129 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 129 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 129 | bool multiply_may_overflow = false; | 1087 | 129 | if (to_scale > from_scale) { | 1088 | 36 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 36 | } | 1090 | | | 1091 | 129 | typename ToFieldType::NativeType max_result = | 1092 | 129 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 129 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 129 | MaxNativeType multiplier {}; | 1096 | 129 | if (from_scale < to_scale) { | 1097 | 36 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 36 | from_scale); | 1099 | 93 | } else if (from_scale > to_scale) { | 1100 | 66 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 66 | to_scale); | 1102 | 66 | } | 1103 | 129 | RETURN_IF_ERROR(std::visit( | 1104 | 129 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 129 | for (size_t i = 0; i < size; i++) { | 1106 | 129 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 129 | multiply_may_overflow, narrow_integral>( | 1108 | 129 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 129 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 129 | params)) { | 1111 | 129 | if (set_nullable) { | 1112 | 129 | null_map_data[i] = 1; | 1113 | 129 | } else { | 1114 | 129 | return params.status; | 1115 | 129 | } | 1116 | 129 | } | 1117 | 129 | } | 1118 | 129 | return Status::OK(); | 1119 | 129 | }, | 1120 | 129 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 129 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 156 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 156 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 156 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 156 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 156 | const auto* col_from = | 1036 | 156 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 156 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 156 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 156 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 156 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 156 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 156 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 156 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 156 | ToDataType::check_type_precision(to_precision); | 1050 | 156 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 156 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 156 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 156 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 156 | bool narrow_integral = | 1056 | 156 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 156 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 156 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 156 | size_t size = col_from->size(); | 1062 | 156 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 156 | NullMap::value_type* null_map_data = nullptr; | 1064 | 156 | if (narrow_integral) { | 1065 | 136 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 136 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 136 | } | 1068 | 156 | CastParameters params; | 1069 | 156 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 156 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 156 | const auto& vec_from = col_from->get_data(); | 1072 | 156 | const auto* vec_from_data = vec_from.data(); | 1073 | 156 | auto& vec_to = col_to->get_data(); | 1074 | 156 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 156 | using MaxFieldType = | 1077 | 156 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 156 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 156 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 156 | Decimal128V3, | 1081 | 156 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 156 | FromFieldType, ToFieldType>>; | 1083 | 156 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 156 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 156 | bool multiply_may_overflow = false; | 1087 | 156 | if (to_scale > from_scale) { | 1088 | 42 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 42 | } | 1090 | | | 1091 | 156 | typename ToFieldType::NativeType max_result = | 1092 | 156 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 156 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 156 | MaxNativeType multiplier {}; | 1096 | 156 | if (from_scale < to_scale) { | 1097 | 42 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 42 | from_scale); | 1099 | 114 | } else if (from_scale > to_scale) { | 1100 | 72 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 72 | to_scale); | 1102 | 72 | } | 1103 | 156 | RETURN_IF_ERROR(std::visit( | 1104 | 156 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 156 | for (size_t i = 0; i < size; i++) { | 1106 | 156 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 156 | multiply_may_overflow, narrow_integral>( | 1108 | 156 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 156 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 156 | params)) { | 1111 | 156 | if (set_nullable) { | 1112 | 156 | null_map_data[i] = 1; | 1113 | 156 | } else { | 1114 | 156 | return params.status; | 1115 | 156 | } | 1116 | 156 | } | 1117 | 156 | } | 1118 | 156 | return Status::OK(); | 1119 | 156 | }, | 1120 | 156 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 156 | if (narrow_integral) { | 1122 | 136 | block.get_by_position(result).column = | 1123 | 136 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 136 | } else { | 1125 | 20 | block.get_by_position(result).column = std::move(col_to); | 1126 | 20 | } | 1127 | 156 | return Status::OK(); | 1128 | 156 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 140 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 140 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 140 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 140 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 140 | const auto* col_from = | 1036 | 140 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 140 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 140 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 140 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 140 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 140 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 140 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 140 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 140 | ToDataType::check_type_precision(to_precision); | 1050 | 140 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 140 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 140 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 140 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 140 | bool narrow_integral = | 1056 | 140 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 140 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 140 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 140 | size_t size = col_from->size(); | 1062 | 140 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 140 | NullMap::value_type* null_map_data = nullptr; | 1064 | 140 | if (narrow_integral) { | 1065 | 140 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 140 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 140 | } | 1068 | 140 | CastParameters params; | 1069 | 140 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 140 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 140 | const auto& vec_from = col_from->get_data(); | 1072 | 140 | const auto* vec_from_data = vec_from.data(); | 1073 | 140 | auto& vec_to = col_to->get_data(); | 1074 | 140 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 140 | using MaxFieldType = | 1077 | 140 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 140 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 140 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 140 | Decimal128V3, | 1081 | 140 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 140 | FromFieldType, ToFieldType>>; | 1083 | 140 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 140 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 140 | bool multiply_may_overflow = false; | 1087 | 140 | if (to_scale > from_scale) { | 1088 | 36 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 36 | } | 1090 | | | 1091 | 140 | typename ToFieldType::NativeType max_result = | 1092 | 140 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 140 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 140 | MaxNativeType multiplier {}; | 1096 | 140 | if (from_scale < to_scale) { | 1097 | 36 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 36 | from_scale); | 1099 | 104 | } else if (from_scale > to_scale) { | 1100 | 80 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 80 | to_scale); | 1102 | 80 | } | 1103 | 140 | RETURN_IF_ERROR(std::visit( | 1104 | 140 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 140 | for (size_t i = 0; i < size; i++) { | 1106 | 140 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 140 | multiply_may_overflow, narrow_integral>( | 1108 | 140 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 140 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 140 | params)) { | 1111 | 140 | if (set_nullable) { | 1112 | 140 | null_map_data[i] = 1; | 1113 | 140 | } else { | 1114 | 140 | return params.status; | 1115 | 140 | } | 1116 | 140 | } | 1117 | 140 | } | 1118 | 140 | return Status::OK(); | 1119 | 140 | }, | 1120 | 140 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 140 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 156 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 156 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 156 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 156 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 156 | const auto* col_from = | 1036 | 156 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 156 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 156 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 156 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 156 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 156 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 156 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 156 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 156 | ToDataType::check_type_precision(to_precision); | 1050 | 156 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 156 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 156 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 156 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 156 | bool narrow_integral = | 1056 | 156 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 156 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 156 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 156 | size_t size = col_from->size(); | 1062 | 156 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 156 | NullMap::value_type* null_map_data = nullptr; | 1064 | 156 | if (narrow_integral) { | 1065 | 136 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 136 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 136 | } | 1068 | 156 | CastParameters params; | 1069 | 156 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 156 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 156 | const auto& vec_from = col_from->get_data(); | 1072 | 156 | const auto* vec_from_data = vec_from.data(); | 1073 | 156 | auto& vec_to = col_to->get_data(); | 1074 | 156 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 156 | using MaxFieldType = | 1077 | 156 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 156 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 156 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 156 | Decimal128V3, | 1081 | 156 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 156 | FromFieldType, ToFieldType>>; | 1083 | 156 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 156 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 156 | bool multiply_may_overflow = false; | 1087 | 156 | if (to_scale > from_scale) { | 1088 | 42 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 42 | } | 1090 | | | 1091 | 156 | typename ToFieldType::NativeType max_result = | 1092 | 156 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 156 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 156 | MaxNativeType multiplier {}; | 1096 | 156 | if (from_scale < to_scale) { | 1097 | 42 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 42 | from_scale); | 1099 | 114 | } else if (from_scale > to_scale) { | 1100 | 74 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 74 | to_scale); | 1102 | 74 | } | 1103 | 156 | RETURN_IF_ERROR(std::visit( | 1104 | 156 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 156 | for (size_t i = 0; i < size; i++) { | 1106 | 156 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 156 | multiply_may_overflow, narrow_integral>( | 1108 | 156 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 156 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 156 | params)) { | 1111 | 156 | if (set_nullable) { | 1112 | 156 | null_map_data[i] = 1; | 1113 | 156 | } else { | 1114 | 156 | return params.status; | 1115 | 156 | } | 1116 | 156 | } | 1117 | 156 | } | 1118 | 156 | return Status::OK(); | 1119 | 156 | }, | 1120 | 156 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 156 | if (narrow_integral) { | 1122 | 136 | block.get_by_position(result).column = | 1123 | 136 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 136 | } else { | 1125 | 20 | block.get_by_position(result).column = std::move(col_to); | 1126 | 20 | } | 1127 | 156 | return Status::OK(); | 1128 | 156 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 140 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 140 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 140 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 140 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 140 | const auto* col_from = | 1036 | 140 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 140 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 140 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 140 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 140 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 140 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 140 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 140 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 140 | ToDataType::check_type_precision(to_precision); | 1050 | 140 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 140 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 140 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 140 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 140 | bool narrow_integral = | 1056 | 140 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 140 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 140 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 140 | size_t size = col_from->size(); | 1062 | 140 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 140 | NullMap::value_type* null_map_data = nullptr; | 1064 | 140 | if (narrow_integral) { | 1065 | 140 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 140 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 140 | } | 1068 | 140 | CastParameters params; | 1069 | 140 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 140 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 140 | const auto& vec_from = col_from->get_data(); | 1072 | 140 | const auto* vec_from_data = vec_from.data(); | 1073 | 140 | auto& vec_to = col_to->get_data(); | 1074 | 140 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 140 | using MaxFieldType = | 1077 | 140 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 140 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 140 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 140 | Decimal128V3, | 1081 | 140 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 140 | FromFieldType, ToFieldType>>; | 1083 | 140 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 140 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 140 | bool multiply_may_overflow = false; | 1087 | 140 | if (to_scale > from_scale) { | 1088 | 36 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 36 | } | 1090 | | | 1091 | 140 | typename ToFieldType::NativeType max_result = | 1092 | 140 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 140 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 140 | MaxNativeType multiplier {}; | 1096 | 140 | if (from_scale < to_scale) { | 1097 | 36 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 36 | from_scale); | 1099 | 104 | } else if (from_scale > to_scale) { | 1100 | 80 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 80 | to_scale); | 1102 | 80 | } | 1103 | 140 | RETURN_IF_ERROR(std::visit( | 1104 | 140 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 140 | for (size_t i = 0; i < size; i++) { | 1106 | 140 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 140 | multiply_may_overflow, narrow_integral>( | 1108 | 140 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 140 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 140 | params)) { | 1111 | 140 | if (set_nullable) { | 1112 | 140 | null_map_data[i] = 1; | 1113 | 140 | } else { | 1114 | 140 | return params.status; | 1115 | 140 | } | 1116 | 140 | } | 1117 | 140 | } | 1118 | 140 | return Status::OK(); | 1119 | 140 | }, | 1120 | 140 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 140 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS2_ILS3_28EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 156 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 156 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 156 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 156 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 156 | const auto* col_from = | 1036 | 156 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 156 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 156 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 156 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 156 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 156 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 156 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 156 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 156 | ToDataType::check_type_precision(to_precision); | 1050 | 156 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 156 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 156 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 156 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 156 | bool narrow_integral = | 1056 | 156 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 156 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 156 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 156 | size_t size = col_from->size(); | 1062 | 156 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 156 | NullMap::value_type* null_map_data = nullptr; | 1064 | 156 | if (narrow_integral) { | 1065 | 136 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 136 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 136 | } | 1068 | 156 | CastParameters params; | 1069 | 156 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 156 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 156 | const auto& vec_from = col_from->get_data(); | 1072 | 156 | const auto* vec_from_data = vec_from.data(); | 1073 | 156 | auto& vec_to = col_to->get_data(); | 1074 | 156 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 156 | using MaxFieldType = | 1077 | 156 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 156 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 156 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 156 | Decimal128V3, | 1081 | 156 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 156 | FromFieldType, ToFieldType>>; | 1083 | 156 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 156 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 156 | bool multiply_may_overflow = false; | 1087 | 156 | if (to_scale > from_scale) { | 1088 | 42 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 42 | } | 1090 | | | 1091 | 156 | typename ToFieldType::NativeType max_result = | 1092 | 156 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 156 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 156 | MaxNativeType multiplier {}; | 1096 | 156 | if (from_scale < to_scale) { | 1097 | 42 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 42 | from_scale); | 1099 | 114 | } else if (from_scale > to_scale) { | 1100 | 74 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 74 | to_scale); | 1102 | 74 | } | 1103 | 156 | RETURN_IF_ERROR(std::visit( | 1104 | 156 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 156 | for (size_t i = 0; i < size; i++) { | 1106 | 156 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 156 | multiply_may_overflow, narrow_integral>( | 1108 | 156 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 156 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 156 | params)) { | 1111 | 156 | if (set_nullable) { | 1112 | 156 | null_map_data[i] = 1; | 1113 | 156 | } else { | 1114 | 156 | return params.status; | 1115 | 156 | } | 1116 | 156 | } | 1117 | 156 | } | 1118 | 156 | return Status::OK(); | 1119 | 156 | }, | 1120 | 156 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 156 | if (narrow_integral) { | 1122 | 136 | block.get_by_position(result).column = | 1123 | 136 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 136 | } else { | 1125 | 20 | block.get_by_position(result).column = std::move(col_to); | 1126 | 20 | } | 1127 | 156 | return Status::OK(); | 1128 | 156 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 36 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 36 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 36 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 36 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 36 | const auto* col_from = | 1036 | 36 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 36 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 36 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 36 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 36 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 36 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 36 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 36 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 36 | ToDataType::check_type_precision(to_precision); | 1050 | 36 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 36 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 36 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 36 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 36 | bool narrow_integral = | 1056 | 36 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 36 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 36 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 36 | size_t size = col_from->size(); | 1062 | 36 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 36 | NullMap::value_type* null_map_data = nullptr; | 1064 | 36 | if (narrow_integral) { | 1065 | 36 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 36 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 36 | } | 1068 | 36 | CastParameters params; | 1069 | 36 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 36 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 36 | const auto& vec_from = col_from->get_data(); | 1072 | 36 | const auto* vec_from_data = vec_from.data(); | 1073 | 36 | auto& vec_to = col_to->get_data(); | 1074 | 36 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 36 | using MaxFieldType = | 1077 | 36 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 36 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 36 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 36 | Decimal128V3, | 1081 | 36 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 36 | FromFieldType, ToFieldType>>; | 1083 | 36 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 36 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 36 | bool multiply_may_overflow = false; | 1087 | 36 | if (to_scale > from_scale) { | 1088 | 36 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 36 | } | 1090 | | | 1091 | 36 | typename ToFieldType::NativeType max_result = | 1092 | 36 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 36 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 36 | MaxNativeType multiplier {}; | 1096 | 36 | if (from_scale < to_scale) { | 1097 | 36 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 36 | from_scale); | 1099 | 36 | } else if (from_scale > to_scale) { | 1100 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 0 | to_scale); | 1102 | 0 | } | 1103 | 36 | RETURN_IF_ERROR(std::visit( | 1104 | 36 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 36 | for (size_t i = 0; i < size; i++) { | 1106 | 36 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 36 | multiply_may_overflow, narrow_integral>( | 1108 | 36 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 36 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 36 | params)) { | 1111 | 36 | if (set_nullable) { | 1112 | 36 | null_map_data[i] = 1; | 1113 | 36 | } else { | 1114 | 36 | return params.status; | 1115 | 36 | } | 1116 | 36 | } | 1117 | 36 | } | 1118 | 36 | return Status::OK(); | 1119 | 36 | }, | 1120 | 36 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 36 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 132 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 132 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 132 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 132 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 132 | const auto* col_from = | 1036 | 132 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 132 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 132 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 132 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 132 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 132 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 132 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 132 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 132 | ToDataType::check_type_precision(to_precision); | 1050 | 132 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 132 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 132 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 132 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 132 | bool narrow_integral = | 1056 | 132 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 132 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 132 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 132 | size_t size = col_from->size(); | 1062 | 132 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 132 | NullMap::value_type* null_map_data = nullptr; | 1064 | 132 | if (narrow_integral) { | 1065 | 32 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 32 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 32 | } | 1068 | 132 | CastParameters params; | 1069 | 132 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 132 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 132 | const auto& vec_from = col_from->get_data(); | 1072 | 132 | const auto* vec_from_data = vec_from.data(); | 1073 | 132 | auto& vec_to = col_to->get_data(); | 1074 | 132 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 132 | using MaxFieldType = | 1077 | 132 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 132 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 132 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 132 | Decimal128V3, | 1081 | 132 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 132 | FromFieldType, ToFieldType>>; | 1083 | 132 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 132 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 132 | bool multiply_may_overflow = false; | 1087 | 132 | if (to_scale > from_scale) { | 1088 | 69 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 69 | } | 1090 | | | 1091 | 132 | typename ToFieldType::NativeType max_result = | 1092 | 132 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 132 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 132 | MaxNativeType multiplier {}; | 1096 | 132 | if (from_scale < to_scale) { | 1097 | 69 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 69 | from_scale); | 1099 | 69 | } else if (from_scale > to_scale) { | 1100 | 30 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 30 | to_scale); | 1102 | 30 | } | 1103 | 132 | RETURN_IF_ERROR(std::visit( | 1104 | 132 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 132 | for (size_t i = 0; i < size; i++) { | 1106 | 132 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 132 | multiply_may_overflow, narrow_integral>( | 1108 | 132 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 132 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 132 | params)) { | 1111 | 132 | if (set_nullable) { | 1112 | 132 | null_map_data[i] = 1; | 1113 | 132 | } else { | 1114 | 132 | return params.status; | 1115 | 132 | } | 1116 | 132 | } | 1117 | 132 | } | 1118 | 132 | return Status::OK(); | 1119 | 132 | }, | 1120 | 132 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 132 | if (narrow_integral) { | 1122 | 32 | block.get_by_position(result).column = | 1123 | 32 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 100 | } else { | 1125 | 100 | block.get_by_position(result).column = std::move(col_to); | 1126 | 100 | } | 1127 | 132 | return Status::OK(); | 1128 | 132 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 92 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 92 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 92 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 92 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 92 | const auto* col_from = | 1036 | 92 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 92 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 92 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 92 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 92 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 92 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 92 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 92 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 92 | ToDataType::check_type_precision(to_precision); | 1050 | 92 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 92 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 92 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 92 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 92 | bool narrow_integral = | 1056 | 92 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 92 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 92 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 92 | size_t size = col_from->size(); | 1062 | 92 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 92 | NullMap::value_type* null_map_data = nullptr; | 1064 | 92 | if (narrow_integral) { | 1065 | 92 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 92 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 92 | } | 1068 | 92 | CastParameters params; | 1069 | 92 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 92 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 92 | const auto& vec_from = col_from->get_data(); | 1072 | 92 | const auto* vec_from_data = vec_from.data(); | 1073 | 92 | auto& vec_to = col_to->get_data(); | 1074 | 92 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 92 | using MaxFieldType = | 1077 | 92 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 92 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 92 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 92 | Decimal128V3, | 1081 | 92 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 92 | FromFieldType, ToFieldType>>; | 1083 | 92 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 92 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 92 | bool multiply_may_overflow = false; | 1087 | 92 | if (to_scale > from_scale) { | 1088 | 66 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 66 | } | 1090 | | | 1091 | 92 | typename ToFieldType::NativeType max_result = | 1092 | 92 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 92 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 92 | MaxNativeType multiplier {}; | 1096 | 92 | if (from_scale < to_scale) { | 1097 | 66 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 66 | from_scale); | 1099 | 66 | } else if (from_scale > to_scale) { | 1100 | 20 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 20 | to_scale); | 1102 | 20 | } | 1103 | 92 | RETURN_IF_ERROR(std::visit( | 1104 | 92 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 92 | for (size_t i = 0; i < size; i++) { | 1106 | 92 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 92 | multiply_may_overflow, narrow_integral>( | 1108 | 92 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 92 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 92 | params)) { | 1111 | 92 | if (set_nullable) { | 1112 | 92 | null_map_data[i] = 1; | 1113 | 92 | } else { | 1114 | 92 | return params.status; | 1115 | 92 | } | 1116 | 92 | } | 1117 | 92 | } | 1118 | 92 | return Status::OK(); | 1119 | 92 | }, | 1120 | 92 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 92 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 180 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 180 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 180 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 180 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 180 | const auto* col_from = | 1036 | 180 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 180 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 180 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 180 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 180 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 180 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 180 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 180 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 180 | ToDataType::check_type_precision(to_precision); | 1050 | 180 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 180 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 180 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 180 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 180 | bool narrow_integral = | 1056 | 180 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 180 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 180 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 180 | size_t size = col_from->size(); | 1062 | 180 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 180 | NullMap::value_type* null_map_data = nullptr; | 1064 | 180 | if (narrow_integral) { | 1065 | 104 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 104 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 104 | } | 1068 | 180 | CastParameters params; | 1069 | 180 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 180 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 180 | const auto& vec_from = col_from->get_data(); | 1072 | 180 | const auto* vec_from_data = vec_from.data(); | 1073 | 180 | auto& vec_to = col_to->get_data(); | 1074 | 180 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 180 | using MaxFieldType = | 1077 | 180 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 180 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 180 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 180 | Decimal128V3, | 1081 | 180 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 180 | FromFieldType, ToFieldType>>; | 1083 | 180 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 180 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 180 | bool multiply_may_overflow = false; | 1087 | 180 | if (to_scale > from_scale) { | 1088 | 86 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 86 | } | 1090 | | | 1091 | 180 | typename ToFieldType::NativeType max_result = | 1092 | 180 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 180 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 180 | MaxNativeType multiplier {}; | 1096 | 180 | if (from_scale < to_scale) { | 1097 | 86 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 86 | from_scale); | 1099 | 94 | } else if (from_scale > to_scale) { | 1100 | 68 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 68 | to_scale); | 1102 | 68 | } | 1103 | 180 | RETURN_IF_ERROR(std::visit( | 1104 | 180 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 180 | for (size_t i = 0; i < size; i++) { | 1106 | 180 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 180 | multiply_may_overflow, narrow_integral>( | 1108 | 180 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 180 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 180 | params)) { | 1111 | 180 | if (set_nullable) { | 1112 | 180 | null_map_data[i] = 1; | 1113 | 180 | } else { | 1114 | 180 | return params.status; | 1115 | 180 | } | 1116 | 180 | } | 1117 | 180 | } | 1118 | 180 | return Status::OK(); | 1119 | 180 | }, | 1120 | 180 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 180 | if (narrow_integral) { | 1122 | 104 | block.get_by_position(result).column = | 1123 | 104 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 104 | } else { | 1125 | 76 | block.get_by_position(result).column = std::move(col_to); | 1126 | 76 | } | 1127 | 180 | return Status::OK(); | 1128 | 180 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 153 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 153 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 153 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 153 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 153 | const auto* col_from = | 1036 | 153 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 153 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 153 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 153 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 153 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 153 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 153 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 153 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 153 | ToDataType::check_type_precision(to_precision); | 1050 | 153 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 153 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 153 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 153 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 153 | bool narrow_integral = | 1056 | 153 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 153 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 153 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 153 | size_t size = col_from->size(); | 1062 | 153 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 153 | NullMap::value_type* null_map_data = nullptr; | 1064 | 153 | if (narrow_integral) { | 1065 | 153 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 153 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 153 | } | 1068 | 153 | CastParameters params; | 1069 | 153 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 153 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 153 | const auto& vec_from = col_from->get_data(); | 1072 | 153 | const auto* vec_from_data = vec_from.data(); | 1073 | 153 | auto& vec_to = col_to->get_data(); | 1074 | 153 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 153 | using MaxFieldType = | 1077 | 153 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 153 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 153 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 153 | Decimal128V3, | 1081 | 153 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 153 | FromFieldType, ToFieldType>>; | 1083 | 153 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 153 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 153 | bool multiply_may_overflow = false; | 1087 | 153 | if (to_scale > from_scale) { | 1088 | 60 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 60 | } | 1090 | | | 1091 | 153 | typename ToFieldType::NativeType max_result = | 1092 | 153 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 153 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 153 | MaxNativeType multiplier {}; | 1096 | 153 | if (from_scale < to_scale) { | 1097 | 60 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 60 | from_scale); | 1099 | 93 | } else if (from_scale > to_scale) { | 1100 | 66 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 66 | to_scale); | 1102 | 66 | } | 1103 | 153 | RETURN_IF_ERROR(std::visit( | 1104 | 153 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 153 | for (size_t i = 0; i < size; i++) { | 1106 | 153 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 153 | multiply_may_overflow, narrow_integral>( | 1108 | 153 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 153 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 153 | params)) { | 1111 | 153 | if (set_nullable) { | 1112 | 153 | null_map_data[i] = 1; | 1113 | 153 | } else { | 1114 | 153 | return params.status; | 1115 | 153 | } | 1116 | 153 | } | 1117 | 153 | } | 1118 | 153 | return Status::OK(); | 1119 | 153 | }, | 1120 | 153 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 153 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 228 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 228 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 228 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 228 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 228 | const auto* col_from = | 1036 | 228 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 228 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 228 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 228 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 228 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 228 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 228 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 228 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 228 | ToDataType::check_type_precision(to_precision); | 1050 | 228 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 228 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 228 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 228 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 228 | bool narrow_integral = | 1056 | 228 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 228 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 228 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 228 | size_t size = col_from->size(); | 1062 | 228 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 228 | NullMap::value_type* null_map_data = nullptr; | 1064 | 228 | if (narrow_integral) { | 1065 | 192 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 192 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 192 | } | 1068 | 228 | CastParameters params; | 1069 | 228 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 228 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 228 | const auto& vec_from = col_from->get_data(); | 1072 | 228 | const auto* vec_from_data = vec_from.data(); | 1073 | 228 | auto& vec_to = col_to->get_data(); | 1074 | 228 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 228 | using MaxFieldType = | 1077 | 228 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 228 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 228 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 228 | Decimal128V3, | 1081 | 228 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 228 | FromFieldType, ToFieldType>>; | 1083 | 228 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 228 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 228 | bool multiply_may_overflow = false; | 1087 | 228 | if (to_scale > from_scale) { | 1088 | 76 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 76 | } | 1090 | | | 1091 | 228 | typename ToFieldType::NativeType max_result = | 1092 | 228 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 228 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 228 | MaxNativeType multiplier {}; | 1096 | 228 | if (from_scale < to_scale) { | 1097 | 76 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 76 | from_scale); | 1099 | 152 | } else if (from_scale > to_scale) { | 1100 | 94 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 94 | to_scale); | 1102 | 94 | } | 1103 | 228 | RETURN_IF_ERROR(std::visit( | 1104 | 228 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 228 | for (size_t i = 0; i < size; i++) { | 1106 | 228 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 228 | multiply_may_overflow, narrow_integral>( | 1108 | 228 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 228 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 228 | params)) { | 1111 | 228 | if (set_nullable) { | 1112 | 228 | null_map_data[i] = 1; | 1113 | 228 | } else { | 1114 | 228 | return params.status; | 1115 | 228 | } | 1116 | 228 | } | 1117 | 228 | } | 1118 | 228 | return Status::OK(); | 1119 | 228 | }, | 1120 | 228 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 228 | if (narrow_integral) { | 1122 | 192 | block.get_by_position(result).column = | 1123 | 192 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 192 | } else { | 1125 | 36 | block.get_by_position(result).column = std::move(col_to); | 1126 | 36 | } | 1127 | 228 | return Status::OK(); | 1128 | 228 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 164 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 164 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 164 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 164 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 164 | const auto* col_from = | 1036 | 164 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 164 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 164 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 164 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 164 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 164 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 164 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 164 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 164 | ToDataType::check_type_precision(to_precision); | 1050 | 164 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 164 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 164 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 164 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 164 | bool narrow_integral = | 1056 | 164 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 164 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 164 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 164 | size_t size = col_from->size(); | 1062 | 164 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 164 | NullMap::value_type* null_map_data = nullptr; | 1064 | 164 | if (narrow_integral) { | 1065 | 164 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 164 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 164 | } | 1068 | 164 | CastParameters params; | 1069 | 164 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 164 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 164 | const auto& vec_from = col_from->get_data(); | 1072 | 164 | const auto* vec_from_data = vec_from.data(); | 1073 | 164 | auto& vec_to = col_to->get_data(); | 1074 | 164 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 164 | using MaxFieldType = | 1077 | 164 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 164 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 164 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 164 | Decimal128V3, | 1081 | 164 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 164 | FromFieldType, ToFieldType>>; | 1083 | 164 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 164 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 164 | bool multiply_may_overflow = false; | 1087 | 164 | if (to_scale > from_scale) { | 1088 | 60 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 60 | } | 1090 | | | 1091 | 164 | typename ToFieldType::NativeType max_result = | 1092 | 164 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 164 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 164 | MaxNativeType multiplier {}; | 1096 | 164 | if (from_scale < to_scale) { | 1097 | 60 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 60 | from_scale); | 1099 | 104 | } else if (from_scale > to_scale) { | 1100 | 80 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 80 | to_scale); | 1102 | 80 | } | 1103 | 164 | RETURN_IF_ERROR(std::visit( | 1104 | 164 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 164 | for (size_t i = 0; i < size; i++) { | 1106 | 164 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 164 | multiply_may_overflow, narrow_integral>( | 1108 | 164 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 164 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 164 | params)) { | 1111 | 164 | if (set_nullable) { | 1112 | 164 | null_map_data[i] = 1; | 1113 | 164 | } else { | 1114 | 164 | return params.status; | 1115 | 164 | } | 1116 | 164 | } | 1117 | 164 | } | 1118 | 164 | return Status::OK(); | 1119 | 164 | }, | 1120 | 164 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 164 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS2_ILS3_29EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 228 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 228 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 228 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 228 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 228 | const auto* col_from = | 1036 | 228 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 228 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 228 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 228 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 228 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 228 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 228 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 228 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 228 | ToDataType::check_type_precision(to_precision); | 1050 | 228 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 228 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 228 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 228 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 228 | bool narrow_integral = | 1056 | 228 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 228 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 228 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 228 | size_t size = col_from->size(); | 1062 | 228 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 228 | NullMap::value_type* null_map_data = nullptr; | 1064 | 228 | if (narrow_integral) { | 1065 | 192 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 192 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 192 | } | 1068 | 228 | CastParameters params; | 1069 | 228 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 228 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 228 | const auto& vec_from = col_from->get_data(); | 1072 | 228 | const auto* vec_from_data = vec_from.data(); | 1073 | 228 | auto& vec_to = col_to->get_data(); | 1074 | 228 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 228 | using MaxFieldType = | 1077 | 228 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 228 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 228 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 228 | Decimal128V3, | 1081 | 228 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 228 | FromFieldType, ToFieldType>>; | 1083 | 228 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 228 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 228 | bool multiply_may_overflow = false; | 1087 | 228 | if (to_scale > from_scale) { | 1088 | 76 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 76 | } | 1090 | | | 1091 | 228 | typename ToFieldType::NativeType max_result = | 1092 | 228 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 228 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 228 | MaxNativeType multiplier {}; | 1096 | 228 | if (from_scale < to_scale) { | 1097 | 76 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 76 | from_scale); | 1099 | 152 | } else if (from_scale > to_scale) { | 1100 | 96 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 96 | to_scale); | 1102 | 96 | } | 1103 | 228 | RETURN_IF_ERROR(std::visit( | 1104 | 228 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 228 | for (size_t i = 0; i < size; i++) { | 1106 | 228 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 228 | multiply_may_overflow, narrow_integral>( | 1108 | 228 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 228 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 228 | params)) { | 1111 | 228 | if (set_nullable) { | 1112 | 228 | null_map_data[i] = 1; | 1113 | 228 | } else { | 1114 | 228 | return params.status; | 1115 | 228 | } | 1116 | 228 | } | 1117 | 228 | } | 1118 | 228 | return Status::OK(); | 1119 | 228 | }, | 1120 | 228 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 228 | if (narrow_integral) { | 1122 | 192 | block.get_by_position(result).column = | 1123 | 192 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 192 | } else { | 1125 | 36 | block.get_by_position(result).column = std::move(col_to); | 1126 | 36 | } | 1127 | 228 | return Status::OK(); | 1128 | 228 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 36 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 36 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 36 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 36 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 36 | const auto* col_from = | 1036 | 36 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 36 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 36 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 36 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 36 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 36 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 36 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 36 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 36 | ToDataType::check_type_precision(to_precision); | 1050 | 36 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 36 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 36 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 36 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 36 | bool narrow_integral = | 1056 | 36 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 36 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 36 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 36 | size_t size = col_from->size(); | 1062 | 36 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 36 | NullMap::value_type* null_map_data = nullptr; | 1064 | 36 | if (narrow_integral) { | 1065 | 36 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 36 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 36 | } | 1068 | 36 | CastParameters params; | 1069 | 36 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 36 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 36 | const auto& vec_from = col_from->get_data(); | 1072 | 36 | const auto* vec_from_data = vec_from.data(); | 1073 | 36 | auto& vec_to = col_to->get_data(); | 1074 | 36 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 36 | using MaxFieldType = | 1077 | 36 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 36 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 36 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 36 | Decimal128V3, | 1081 | 36 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 36 | FromFieldType, ToFieldType>>; | 1083 | 36 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 36 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 36 | bool multiply_may_overflow = false; | 1087 | 36 | if (to_scale > from_scale) { | 1088 | 36 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 36 | } | 1090 | | | 1091 | 36 | typename ToFieldType::NativeType max_result = | 1092 | 36 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 36 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 36 | MaxNativeType multiplier {}; | 1096 | 36 | if (from_scale < to_scale) { | 1097 | 36 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 36 | from_scale); | 1099 | 36 | } else if (from_scale > to_scale) { | 1100 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 0 | to_scale); | 1102 | 0 | } | 1103 | 36 | RETURN_IF_ERROR(std::visit( | 1104 | 36 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 36 | for (size_t i = 0; i < size; i++) { | 1106 | 36 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 36 | multiply_may_overflow, narrow_integral>( | 1108 | 36 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 36 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 36 | params)) { | 1111 | 36 | if (set_nullable) { | 1112 | 36 | null_map_data[i] = 1; | 1113 | 36 | } else { | 1114 | 36 | return params.status; | 1115 | 36 | } | 1116 | 36 | } | 1117 | 36 | } | 1118 | 36 | return Status::OK(); | 1119 | 36 | }, | 1120 | 36 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 36 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 132 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 132 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 132 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 132 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 132 | const auto* col_from = | 1036 | 132 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 132 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 132 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 132 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 132 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 132 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 132 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 132 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 132 | ToDataType::check_type_precision(to_precision); | 1050 | 132 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 132 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 132 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 132 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 132 | bool narrow_integral = | 1056 | 132 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 132 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 132 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 132 | size_t size = col_from->size(); | 1062 | 132 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 132 | NullMap::value_type* null_map_data = nullptr; | 1064 | 132 | if (narrow_integral) { | 1065 | 32 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 32 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 32 | } | 1068 | 132 | CastParameters params; | 1069 | 132 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 132 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 132 | const auto& vec_from = col_from->get_data(); | 1072 | 132 | const auto* vec_from_data = vec_from.data(); | 1073 | 132 | auto& vec_to = col_to->get_data(); | 1074 | 132 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 132 | using MaxFieldType = | 1077 | 132 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 132 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 132 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 132 | Decimal128V3, | 1081 | 132 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 132 | FromFieldType, ToFieldType>>; | 1083 | 132 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 132 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 132 | bool multiply_may_overflow = false; | 1087 | 132 | if (to_scale > from_scale) { | 1088 | 70 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 70 | } | 1090 | | | 1091 | 132 | typename ToFieldType::NativeType max_result = | 1092 | 132 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 132 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 132 | MaxNativeType multiplier {}; | 1096 | 132 | if (from_scale < to_scale) { | 1097 | 70 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 70 | from_scale); | 1099 | 70 | } else if (from_scale > to_scale) { | 1100 | 30 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 30 | to_scale); | 1102 | 30 | } | 1103 | 132 | RETURN_IF_ERROR(std::visit( | 1104 | 132 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 132 | for (size_t i = 0; i < size; i++) { | 1106 | 132 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 132 | multiply_may_overflow, narrow_integral>( | 1108 | 132 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 132 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 132 | params)) { | 1111 | 132 | if (set_nullable) { | 1112 | 132 | null_map_data[i] = 1; | 1113 | 132 | } else { | 1114 | 132 | return params.status; | 1115 | 132 | } | 1116 | 132 | } | 1117 | 132 | } | 1118 | 132 | return Status::OK(); | 1119 | 132 | }, | 1120 | 132 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 132 | if (narrow_integral) { | 1122 | 32 | block.get_by_position(result).column = | 1123 | 32 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 100 | } else { | 1125 | 100 | block.get_by_position(result).column = std::move(col_to); | 1126 | 100 | } | 1127 | 132 | return Status::OK(); | 1128 | 132 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 60 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 60 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 60 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 60 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 60 | const auto* col_from = | 1036 | 60 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 60 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 60 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 60 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 60 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 60 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 60 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 60 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 60 | ToDataType::check_type_precision(to_precision); | 1050 | 60 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 60 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 60 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 60 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 60 | bool narrow_integral = | 1056 | 60 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 60 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 60 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 60 | size_t size = col_from->size(); | 1062 | 60 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 60 | NullMap::value_type* null_map_data = nullptr; | 1064 | 60 | if (narrow_integral) { | 1065 | 60 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 60 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 60 | } | 1068 | 60 | CastParameters params; | 1069 | 60 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 60 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 60 | const auto& vec_from = col_from->get_data(); | 1072 | 60 | const auto* vec_from_data = vec_from.data(); | 1073 | 60 | auto& vec_to = col_to->get_data(); | 1074 | 60 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 60 | using MaxFieldType = | 1077 | 60 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 60 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 60 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 60 | Decimal128V3, | 1081 | 60 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 60 | FromFieldType, ToFieldType>>; | 1083 | 60 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 60 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 60 | bool multiply_may_overflow = false; | 1087 | 60 | if (to_scale > from_scale) { | 1088 | 60 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 60 | } | 1090 | | | 1091 | 60 | typename ToFieldType::NativeType max_result = | 1092 | 60 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 60 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 60 | MaxNativeType multiplier {}; | 1096 | 60 | if (from_scale < to_scale) { | 1097 | 60 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 60 | from_scale); | 1099 | 60 | } else if (from_scale > to_scale) { | 1100 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 0 | to_scale); | 1102 | 0 | } | 1103 | 60 | RETURN_IF_ERROR(std::visit( | 1104 | 60 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 60 | for (size_t i = 0; i < size; i++) { | 1106 | 60 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 60 | multiply_may_overflow, narrow_integral>( | 1108 | 60 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 60 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 60 | params)) { | 1111 | 60 | if (set_nullable) { | 1112 | 60 | null_map_data[i] = 1; | 1113 | 60 | } else { | 1114 | 60 | return params.status; | 1115 | 60 | } | 1116 | 60 | } | 1117 | 60 | } | 1118 | 60 | return Status::OK(); | 1119 | 60 | }, | 1120 | 60 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 60 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 204 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 204 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 204 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 204 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 204 | const auto* col_from = | 1036 | 204 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 204 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 204 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 204 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 204 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 204 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 204 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 204 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 204 | ToDataType::check_type_precision(to_precision); | 1050 | 204 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 204 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 204 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 204 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 204 | bool narrow_integral = | 1056 | 204 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 204 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 204 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 204 | size_t size = col_from->size(); | 1062 | 204 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 204 | NullMap::value_type* null_map_data = nullptr; | 1064 | 204 | if (narrow_integral) { | 1065 | 56 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 56 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 56 | } | 1068 | 204 | CastParameters params; | 1069 | 204 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 204 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 204 | const auto& vec_from = col_from->get_data(); | 1072 | 204 | const auto* vec_from_data = vec_from.data(); | 1073 | 204 | auto& vec_to = col_to->get_data(); | 1074 | 204 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 204 | using MaxFieldType = | 1077 | 204 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 204 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 204 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 204 | Decimal128V3, | 1081 | 204 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 204 | FromFieldType, ToFieldType>>; | 1083 | 204 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 204 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 204 | bool multiply_may_overflow = false; | 1087 | 204 | if (to_scale > from_scale) { | 1088 | 99 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 99 | } | 1090 | | | 1091 | 204 | typename ToFieldType::NativeType max_result = | 1092 | 204 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 204 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 204 | MaxNativeType multiplier {}; | 1096 | 204 | if (from_scale < to_scale) { | 1097 | 99 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 99 | from_scale); | 1099 | 105 | } else if (from_scale > to_scale) { | 1100 | 56 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 56 | to_scale); | 1102 | 56 | } | 1103 | 204 | RETURN_IF_ERROR(std::visit( | 1104 | 204 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 204 | for (size_t i = 0; i < size; i++) { | 1106 | 204 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 204 | multiply_may_overflow, narrow_integral>( | 1108 | 204 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 204 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 204 | params)) { | 1111 | 204 | if (set_nullable) { | 1112 | 204 | null_map_data[i] = 1; | 1113 | 204 | } else { | 1114 | 204 | return params.status; | 1115 | 204 | } | 1116 | 204 | } | 1117 | 204 | } | 1118 | 204 | return Status::OK(); | 1119 | 204 | }, | 1120 | 204 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 204 | if (narrow_integral) { | 1122 | 56 | block.get_by_position(result).column = | 1123 | 56 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 148 | } else { | 1125 | 148 | block.get_by_position(result).column = std::move(col_to); | 1126 | 148 | } | 1127 | 204 | return Status::OK(); | 1128 | 204 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 92 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 92 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 92 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 92 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 92 | const auto* col_from = | 1036 | 92 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 92 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 92 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 92 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 92 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 92 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 92 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 92 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 92 | ToDataType::check_type_precision(to_precision); | 1050 | 92 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 92 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 92 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 92 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 92 | bool narrow_integral = | 1056 | 92 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 92 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 92 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 92 | size_t size = col_from->size(); | 1062 | 92 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 92 | NullMap::value_type* null_map_data = nullptr; | 1064 | 92 | if (narrow_integral) { | 1065 | 92 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 92 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 92 | } | 1068 | 92 | CastParameters params; | 1069 | 92 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 92 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 92 | const auto& vec_from = col_from->get_data(); | 1072 | 92 | const auto* vec_from_data = vec_from.data(); | 1073 | 92 | auto& vec_to = col_to->get_data(); | 1074 | 92 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 92 | using MaxFieldType = | 1077 | 92 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 92 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 92 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 92 | Decimal128V3, | 1081 | 92 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 92 | FromFieldType, ToFieldType>>; | 1083 | 92 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 92 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 92 | bool multiply_may_overflow = false; | 1087 | 92 | if (to_scale > from_scale) { | 1088 | 66 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 66 | } | 1090 | | | 1091 | 92 | typename ToFieldType::NativeType max_result = | 1092 | 92 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 92 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 92 | MaxNativeType multiplier {}; | 1096 | 92 | if (from_scale < to_scale) { | 1097 | 66 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 66 | from_scale); | 1099 | 66 | } else if (from_scale > to_scale) { | 1100 | 20 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 20 | to_scale); | 1102 | 20 | } | 1103 | 92 | RETURN_IF_ERROR(std::visit( | 1104 | 92 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 92 | for (size_t i = 0; i < size; i++) { | 1106 | 92 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 92 | multiply_may_overflow, narrow_integral>( | 1108 | 92 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 92 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 92 | params)) { | 1111 | 92 | if (set_nullable) { | 1112 | 92 | null_map_data[i] = 1; | 1113 | 92 | } else { | 1114 | 92 | return params.status; | 1115 | 92 | } | 1116 | 92 | } | 1117 | 92 | } | 1118 | 92 | return Status::OK(); | 1119 | 92 | }, | 1120 | 92 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 92 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 186 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 186 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 186 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 186 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 186 | const auto* col_from = | 1036 | 186 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 186 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 186 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 186 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 186 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 186 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 186 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 186 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 186 | ToDataType::check_type_precision(to_precision); | 1050 | 186 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 186 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 186 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 186 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 186 | bool narrow_integral = | 1056 | 186 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 186 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 186 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 186 | size_t size = col_from->size(); | 1062 | 186 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 186 | NullMap::value_type* null_map_data = nullptr; | 1064 | 186 | if (narrow_integral) { | 1065 | 110 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 110 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 110 | } | 1068 | 186 | CastParameters params; | 1069 | 186 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 186 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 186 | const auto& vec_from = col_from->get_data(); | 1072 | 186 | const auto* vec_from_data = vec_from.data(); | 1073 | 186 | auto& vec_to = col_to->get_data(); | 1074 | 186 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 186 | using MaxFieldType = | 1077 | 186 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 186 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 186 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 186 | Decimal128V3, | 1081 | 186 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 186 | FromFieldType, ToFieldType>>; | 1083 | 186 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 186 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 186 | bool multiply_may_overflow = false; | 1087 | 186 | if (to_scale > from_scale) { | 1088 | 91 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 91 | } | 1090 | | | 1091 | 186 | typename ToFieldType::NativeType max_result = | 1092 | 186 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 186 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 186 | MaxNativeType multiplier {}; | 1096 | 186 | if (from_scale < to_scale) { | 1097 | 91 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 91 | from_scale); | 1099 | 95 | } else if (from_scale > to_scale) { | 1100 | 68 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 68 | to_scale); | 1102 | 68 | } | 1103 | 186 | RETURN_IF_ERROR(std::visit( | 1104 | 186 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 186 | for (size_t i = 0; i < size; i++) { | 1106 | 186 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 186 | multiply_may_overflow, narrow_integral>( | 1108 | 186 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 186 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 186 | params)) { | 1111 | 186 | if (set_nullable) { | 1112 | 186 | null_map_data[i] = 1; | 1113 | 186 | } else { | 1114 | 186 | return params.status; | 1115 | 186 | } | 1116 | 186 | } | 1117 | 186 | } | 1118 | 186 | return Status::OK(); | 1119 | 186 | }, | 1120 | 186 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 186 | if (narrow_integral) { | 1122 | 110 | block.get_by_position(result).column = | 1123 | 110 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 110 | } else { | 1125 | 76 | block.get_by_position(result).column = std::move(col_to); | 1126 | 76 | } | 1127 | 186 | return Status::OK(); | 1128 | 186 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 153 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 153 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 153 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 153 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 153 | const auto* col_from = | 1036 | 153 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 153 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 153 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 153 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 153 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 153 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 153 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 153 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 153 | ToDataType::check_type_precision(to_precision); | 1050 | 153 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 153 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 153 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 153 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 153 | bool narrow_integral = | 1056 | 153 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 153 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 153 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 153 | size_t size = col_from->size(); | 1062 | 153 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 153 | NullMap::value_type* null_map_data = nullptr; | 1064 | 153 | if (narrow_integral) { | 1065 | 153 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 153 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 153 | } | 1068 | 153 | CastParameters params; | 1069 | 153 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 153 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 153 | const auto& vec_from = col_from->get_data(); | 1072 | 153 | const auto* vec_from_data = vec_from.data(); | 1073 | 153 | auto& vec_to = col_to->get_data(); | 1074 | 153 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 153 | using MaxFieldType = | 1077 | 153 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 153 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 153 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 153 | Decimal128V3, | 1081 | 153 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 153 | FromFieldType, ToFieldType>>; | 1083 | 153 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 153 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 153 | bool multiply_may_overflow = false; | 1087 | 153 | if (to_scale > from_scale) { | 1088 | 60 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 60 | } | 1090 | | | 1091 | 153 | typename ToFieldType::NativeType max_result = | 1092 | 153 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 153 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 153 | MaxNativeType multiplier {}; | 1096 | 153 | if (from_scale < to_scale) { | 1097 | 60 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 60 | from_scale); | 1099 | 93 | } else if (from_scale > to_scale) { | 1100 | 66 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 66 | to_scale); | 1102 | 66 | } | 1103 | 153 | RETURN_IF_ERROR(std::visit( | 1104 | 153 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 153 | for (size_t i = 0; i < size; i++) { | 1106 | 153 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 153 | multiply_may_overflow, narrow_integral>( | 1108 | 153 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 153 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 153 | params)) { | 1111 | 153 | if (set_nullable) { | 1112 | 153 | null_map_data[i] = 1; | 1113 | 153 | } else { | 1114 | 153 | return params.status; | 1115 | 153 | } | 1116 | 153 | } | 1117 | 153 | } | 1118 | 153 | return Status::OK(); | 1119 | 153 | }, | 1120 | 153 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 153 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS2_ILS3_30EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 228 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 228 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 228 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 228 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 228 | const auto* col_from = | 1036 | 228 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 228 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 228 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 228 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 228 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 228 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 228 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 228 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 228 | ToDataType::check_type_precision(to_precision); | 1050 | 228 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 228 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 228 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 228 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 228 | bool narrow_integral = | 1056 | 228 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 228 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 228 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 228 | size_t size = col_from->size(); | 1062 | 228 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 228 | NullMap::value_type* null_map_data = nullptr; | 1064 | 228 | if (narrow_integral) { | 1065 | 192 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 192 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 192 | } | 1068 | 228 | CastParameters params; | 1069 | 228 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 228 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 228 | const auto& vec_from = col_from->get_data(); | 1072 | 228 | const auto* vec_from_data = vec_from.data(); | 1073 | 228 | auto& vec_to = col_to->get_data(); | 1074 | 228 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 228 | using MaxFieldType = | 1077 | 228 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 228 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 228 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 228 | Decimal128V3, | 1081 | 228 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 228 | FromFieldType, ToFieldType>>; | 1083 | 228 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 228 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 228 | bool multiply_may_overflow = false; | 1087 | 228 | if (to_scale > from_scale) { | 1088 | 76 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 76 | } | 1090 | | | 1091 | 228 | typename ToFieldType::NativeType max_result = | 1092 | 228 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 228 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 228 | MaxNativeType multiplier {}; | 1096 | 228 | if (from_scale < to_scale) { | 1097 | 76 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 76 | from_scale); | 1099 | 152 | } else if (from_scale > to_scale) { | 1100 | 94 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 94 | to_scale); | 1102 | 94 | } | 1103 | 228 | RETURN_IF_ERROR(std::visit( | 1104 | 228 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 228 | for (size_t i = 0; i < size; i++) { | 1106 | 228 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 228 | multiply_may_overflow, narrow_integral>( | 1108 | 228 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 228 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 228 | params)) { | 1111 | 228 | if (set_nullable) { | 1112 | 228 | null_map_data[i] = 1; | 1113 | 228 | } else { | 1114 | 228 | return params.status; | 1115 | 228 | } | 1116 | 228 | } | 1117 | 228 | } | 1118 | 228 | return Status::OK(); | 1119 | 228 | }, | 1120 | 228 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 228 | if (narrow_integral) { | 1122 | 192 | block.get_by_position(result).column = | 1123 | 192 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 192 | } else { | 1125 | 36 | block.get_by_position(result).column = std::move(col_to); | 1126 | 36 | } | 1127 | 228 | return Status::OK(); | 1128 | 228 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 36 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 36 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 36 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 36 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 36 | const auto* col_from = | 1036 | 36 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 36 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 36 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 36 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 36 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 36 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 36 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 36 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 36 | ToDataType::check_type_precision(to_precision); | 1050 | 36 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 36 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 36 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 36 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 36 | bool narrow_integral = | 1056 | 36 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 36 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 36 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 36 | size_t size = col_from->size(); | 1062 | 36 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 36 | NullMap::value_type* null_map_data = nullptr; | 1064 | 36 | if (narrow_integral) { | 1065 | 36 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 36 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 36 | } | 1068 | 36 | CastParameters params; | 1069 | 36 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 36 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 36 | const auto& vec_from = col_from->get_data(); | 1072 | 36 | const auto* vec_from_data = vec_from.data(); | 1073 | 36 | auto& vec_to = col_to->get_data(); | 1074 | 36 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 36 | using MaxFieldType = | 1077 | 36 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 36 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 36 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 36 | Decimal128V3, | 1081 | 36 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 36 | FromFieldType, ToFieldType>>; | 1083 | 36 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 36 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 36 | bool multiply_may_overflow = false; | 1087 | 36 | if (to_scale > from_scale) { | 1088 | 36 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 36 | } | 1090 | | | 1091 | 36 | typename ToFieldType::NativeType max_result = | 1092 | 36 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 36 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 36 | MaxNativeType multiplier {}; | 1096 | 36 | if (from_scale < to_scale) { | 1097 | 36 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 36 | from_scale); | 1099 | 36 | } else if (from_scale > to_scale) { | 1100 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 0 | to_scale); | 1102 | 0 | } | 1103 | 36 | RETURN_IF_ERROR(std::visit( | 1104 | 36 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 36 | for (size_t i = 0; i < size; i++) { | 1106 | 36 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 36 | multiply_may_overflow, narrow_integral>( | 1108 | 36 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 36 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 36 | params)) { | 1111 | 36 | if (set_nullable) { | 1112 | 36 | null_map_data[i] = 1; | 1113 | 36 | } else { | 1114 | 36 | return params.status; | 1115 | 36 | } | 1116 | 36 | } | 1117 | 36 | } | 1118 | 36 | return Status::OK(); | 1119 | 36 | }, | 1120 | 36 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 36 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 132 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 132 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 132 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 132 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 132 | const auto* col_from = | 1036 | 132 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 132 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 132 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 132 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 132 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 132 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 132 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 132 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 132 | ToDataType::check_type_precision(to_precision); | 1050 | 132 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 132 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 132 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 132 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 132 | bool narrow_integral = | 1056 | 132 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 132 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 132 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 132 | size_t size = col_from->size(); | 1062 | 132 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 132 | NullMap::value_type* null_map_data = nullptr; | 1064 | 132 | if (narrow_integral) { | 1065 | 32 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 32 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 32 | } | 1068 | 132 | CastParameters params; | 1069 | 132 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 132 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 132 | const auto& vec_from = col_from->get_data(); | 1072 | 132 | const auto* vec_from_data = vec_from.data(); | 1073 | 132 | auto& vec_to = col_to->get_data(); | 1074 | 132 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 132 | using MaxFieldType = | 1077 | 132 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 132 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 132 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 132 | Decimal128V3, | 1081 | 132 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 132 | FromFieldType, ToFieldType>>; | 1083 | 132 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 132 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 132 | bool multiply_may_overflow = false; | 1087 | 132 | if (to_scale > from_scale) { | 1088 | 70 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 70 | } | 1090 | | | 1091 | 132 | typename ToFieldType::NativeType max_result = | 1092 | 132 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 132 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 132 | MaxNativeType multiplier {}; | 1096 | 132 | if (from_scale < to_scale) { | 1097 | 70 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 70 | from_scale); | 1099 | 70 | } else if (from_scale > to_scale) { | 1100 | 30 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 30 | to_scale); | 1102 | 30 | } | 1103 | 132 | RETURN_IF_ERROR(std::visit( | 1104 | 132 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 132 | for (size_t i = 0; i < size; i++) { | 1106 | 132 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 132 | multiply_may_overflow, narrow_integral>( | 1108 | 132 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 132 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 132 | params)) { | 1111 | 132 | if (set_nullable) { | 1112 | 132 | null_map_data[i] = 1; | 1113 | 132 | } else { | 1114 | 132 | return params.status; | 1115 | 132 | } | 1116 | 132 | } | 1117 | 132 | } | 1118 | 132 | return Status::OK(); | 1119 | 132 | }, | 1120 | 132 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 132 | if (narrow_integral) { | 1122 | 32 | block.get_by_position(result).column = | 1123 | 32 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 100 | } else { | 1125 | 100 | block.get_by_position(result).column = std::move(col_to); | 1126 | 100 | } | 1127 | 132 | return Status::OK(); | 1128 | 132 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 60 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 60 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 60 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 60 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 60 | const auto* col_from = | 1036 | 60 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 60 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 60 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 60 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 60 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 60 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 60 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 60 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 60 | ToDataType::check_type_precision(to_precision); | 1050 | 60 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 60 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 60 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 60 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 60 | bool narrow_integral = | 1056 | 60 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 60 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 60 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 60 | size_t size = col_from->size(); | 1062 | 60 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 60 | NullMap::value_type* null_map_data = nullptr; | 1064 | 60 | if (narrow_integral) { | 1065 | 60 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 60 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 60 | } | 1068 | 60 | CastParameters params; | 1069 | 60 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 60 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 60 | const auto& vec_from = col_from->get_data(); | 1072 | 60 | const auto* vec_from_data = vec_from.data(); | 1073 | 60 | auto& vec_to = col_to->get_data(); | 1074 | 60 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 60 | using MaxFieldType = | 1077 | 60 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 60 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 60 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 60 | Decimal128V3, | 1081 | 60 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 60 | FromFieldType, ToFieldType>>; | 1083 | 60 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 60 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 60 | bool multiply_may_overflow = false; | 1087 | 60 | if (to_scale > from_scale) { | 1088 | 60 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 60 | } | 1090 | | | 1091 | 60 | typename ToFieldType::NativeType max_result = | 1092 | 60 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 60 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 60 | MaxNativeType multiplier {}; | 1096 | 60 | if (from_scale < to_scale) { | 1097 | 60 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 60 | from_scale); | 1099 | 60 | } else if (from_scale > to_scale) { | 1100 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 0 | to_scale); | 1102 | 0 | } | 1103 | 60 | RETURN_IF_ERROR(std::visit( | 1104 | 60 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 60 | for (size_t i = 0; i < size; i++) { | 1106 | 60 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 60 | multiply_may_overflow, narrow_integral>( | 1108 | 60 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 60 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 60 | params)) { | 1111 | 60 | if (set_nullable) { | 1112 | 60 | null_map_data[i] = 1; | 1113 | 60 | } else { | 1114 | 60 | return params.status; | 1115 | 60 | } | 1116 | 60 | } | 1117 | 60 | } | 1118 | 60 | return Status::OK(); | 1119 | 60 | }, | 1120 | 60 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 60 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 204 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 204 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 204 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 204 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 204 | const auto* col_from = | 1036 | 204 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 204 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 204 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 204 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 204 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 204 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 204 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 204 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 204 | ToDataType::check_type_precision(to_precision); | 1050 | 204 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 204 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 204 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 204 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 204 | bool narrow_integral = | 1056 | 204 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 204 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 204 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 204 | size_t size = col_from->size(); | 1062 | 204 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 204 | NullMap::value_type* null_map_data = nullptr; | 1064 | 204 | if (narrow_integral) { | 1065 | 56 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 56 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 56 | } | 1068 | 204 | CastParameters params; | 1069 | 204 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 204 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 204 | const auto& vec_from = col_from->get_data(); | 1072 | 204 | const auto* vec_from_data = vec_from.data(); | 1073 | 204 | auto& vec_to = col_to->get_data(); | 1074 | 204 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 204 | using MaxFieldType = | 1077 | 204 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 204 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 204 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 204 | Decimal128V3, | 1081 | 204 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 204 | FromFieldType, ToFieldType>>; | 1083 | 204 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 204 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 204 | bool multiply_may_overflow = false; | 1087 | 204 | if (to_scale > from_scale) { | 1088 | 100 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 100 | } | 1090 | | | 1091 | 204 | typename ToFieldType::NativeType max_result = | 1092 | 204 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 204 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 204 | MaxNativeType multiplier {}; | 1096 | 204 | if (from_scale < to_scale) { | 1097 | 100 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 100 | from_scale); | 1099 | 104 | } else if (from_scale > to_scale) { | 1100 | 56 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 56 | to_scale); | 1102 | 56 | } | 1103 | 204 | RETURN_IF_ERROR(std::visit( | 1104 | 204 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 204 | for (size_t i = 0; i < size; i++) { | 1106 | 204 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 204 | multiply_may_overflow, narrow_integral>( | 1108 | 204 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 204 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 204 | params)) { | 1111 | 204 | if (set_nullable) { | 1112 | 204 | null_map_data[i] = 1; | 1113 | 204 | } else { | 1114 | 204 | return params.status; | 1115 | 204 | } | 1116 | 204 | } | 1117 | 204 | } | 1118 | 204 | return Status::OK(); | 1119 | 204 | }, | 1120 | 204 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 204 | if (narrow_integral) { | 1122 | 56 | block.get_by_position(result).column = | 1123 | 56 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 148 | } else { | 1125 | 148 | block.get_by_position(result).column = std::move(col_to); | 1126 | 148 | } | 1127 | 204 | return Status::OK(); | 1128 | 204 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 60 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 60 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 60 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 60 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 60 | const auto* col_from = | 1036 | 60 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 60 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 60 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 60 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 60 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 60 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 60 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 60 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 60 | ToDataType::check_type_precision(to_precision); | 1050 | 60 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 60 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 60 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 60 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 60 | bool narrow_integral = | 1056 | 60 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 60 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 60 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 60 | size_t size = col_from->size(); | 1062 | 60 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 60 | NullMap::value_type* null_map_data = nullptr; | 1064 | 60 | if (narrow_integral) { | 1065 | 60 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 60 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 60 | } | 1068 | 60 | CastParameters params; | 1069 | 60 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 60 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 60 | const auto& vec_from = col_from->get_data(); | 1072 | 60 | const auto* vec_from_data = vec_from.data(); | 1073 | 60 | auto& vec_to = col_to->get_data(); | 1074 | 60 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 60 | using MaxFieldType = | 1077 | 60 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 60 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 60 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 60 | Decimal128V3, | 1081 | 60 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 60 | FromFieldType, ToFieldType>>; | 1083 | 60 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 60 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 60 | bool multiply_may_overflow = false; | 1087 | 60 | if (to_scale > from_scale) { | 1088 | 60 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 60 | } | 1090 | | | 1091 | 60 | typename ToFieldType::NativeType max_result = | 1092 | 60 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 60 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 60 | MaxNativeType multiplier {}; | 1096 | 60 | if (from_scale < to_scale) { | 1097 | 60 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 60 | from_scale); | 1099 | 60 | } else if (from_scale > to_scale) { | 1100 | 0 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 0 | to_scale); | 1102 | 0 | } | 1103 | 60 | RETURN_IF_ERROR(std::visit( | 1104 | 60 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 60 | for (size_t i = 0; i < size; i++) { | 1106 | 60 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 60 | multiply_may_overflow, narrow_integral>( | 1108 | 60 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 60 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 60 | params)) { | 1111 | 60 | if (set_nullable) { | 1112 | 60 | null_map_data[i] = 1; | 1113 | 60 | } else { | 1114 | 60 | return params.status; | 1115 | 60 | } | 1116 | 60 | } | 1117 | 60 | } | 1118 | 60 | return Status::OK(); | 1119 | 60 | }, | 1120 | 60 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 60 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS2_ILS3_35EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 204 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 204 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 204 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 204 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 204 | const auto* col_from = | 1036 | 204 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 204 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 204 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 204 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 204 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 204 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 204 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 204 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 204 | ToDataType::check_type_precision(to_precision); | 1050 | 204 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 204 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 204 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 204 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 204 | bool narrow_integral = | 1056 | 204 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 204 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 204 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 204 | size_t size = col_from->size(); | 1062 | 204 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 204 | NullMap::value_type* null_map_data = nullptr; | 1064 | 204 | if (narrow_integral) { | 1065 | 56 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 56 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 56 | } | 1068 | 204 | CastParameters params; | 1069 | 204 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 204 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 204 | const auto& vec_from = col_from->get_data(); | 1072 | 204 | const auto* vec_from_data = vec_from.data(); | 1073 | 204 | auto& vec_to = col_to->get_data(); | 1074 | 204 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 204 | using MaxFieldType = | 1077 | 204 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 204 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 204 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 204 | Decimal128V3, | 1081 | 204 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 204 | FromFieldType, ToFieldType>>; | 1083 | 204 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 204 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 204 | bool multiply_may_overflow = false; | 1087 | 204 | if (to_scale > from_scale) { | 1088 | 99 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 99 | } | 1090 | | | 1091 | 204 | typename ToFieldType::NativeType max_result = | 1092 | 204 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 204 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 204 | MaxNativeType multiplier {}; | 1096 | 204 | if (from_scale < to_scale) { | 1097 | 99 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 99 | from_scale); | 1099 | 105 | } else if (from_scale > to_scale) { | 1100 | 56 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 56 | to_scale); | 1102 | 56 | } | 1103 | 204 | RETURN_IF_ERROR(std::visit( | 1104 | 204 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 204 | for (size_t i = 0; i < size; i++) { | 1106 | 204 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 204 | multiply_may_overflow, narrow_integral>( | 1108 | 204 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 204 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 204 | params)) { | 1111 | 204 | if (set_nullable) { | 1112 | 204 | null_map_data[i] = 1; | 1113 | 204 | } else { | 1114 | 204 | return params.status; | 1115 | 204 | } | 1116 | 204 | } | 1117 | 204 | } | 1118 | 204 | return Status::OK(); | 1119 | 204 | }, | 1120 | 204 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 204 | if (narrow_integral) { | 1122 | 56 | block.get_by_position(result).column = | 1123 | 56 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 148 | } else { | 1125 | 148 | block.get_by_position(result).column = std::move(col_to); | 1126 | 148 | } | 1127 | 204 | return Status::OK(); | 1128 | 204 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 92 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 92 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 92 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 92 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 92 | const auto* col_from = | 1036 | 92 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 92 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 92 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 92 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 92 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 92 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 92 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 92 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 92 | ToDataType::check_type_precision(to_precision); | 1050 | 92 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 92 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 92 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 92 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 92 | bool narrow_integral = | 1056 | 92 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 92 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 92 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 92 | size_t size = col_from->size(); | 1062 | 92 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 92 | NullMap::value_type* null_map_data = nullptr; | 1064 | 92 | if (narrow_integral) { | 1065 | 92 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 92 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 92 | } | 1068 | 92 | CastParameters params; | 1069 | 92 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 92 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 92 | const auto& vec_from = col_from->get_data(); | 1072 | 92 | const auto* vec_from_data = vec_from.data(); | 1073 | 92 | auto& vec_to = col_to->get_data(); | 1074 | 92 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 92 | using MaxFieldType = | 1077 | 92 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 92 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 92 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 92 | Decimal128V3, | 1081 | 92 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 92 | FromFieldType, ToFieldType>>; | 1083 | 92 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 92 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 92 | bool multiply_may_overflow = false; | 1087 | 92 | if (to_scale > from_scale) { | 1088 | 66 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 66 | } | 1090 | | | 1091 | 92 | typename ToFieldType::NativeType max_result = | 1092 | 92 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 92 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 92 | MaxNativeType multiplier {}; | 1096 | 92 | if (from_scale < to_scale) { | 1097 | 66 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 66 | from_scale); | 1099 | 66 | } else if (from_scale > to_scale) { | 1100 | 20 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 20 | to_scale); | 1102 | 20 | } | 1103 | 92 | RETURN_IF_ERROR(std::visit( | 1104 | 92 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 92 | for (size_t i = 0; i < size; i++) { | 1106 | 92 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 92 | multiply_may_overflow, narrow_integral>( | 1108 | 92 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 92 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 92 | params)) { | 1111 | 92 | if (set_nullable) { | 1112 | 92 | null_map_data[i] = 1; | 1113 | 92 | } else { | 1114 | 92 | return params.status; | 1115 | 92 | } | 1116 | 92 | } | 1117 | 92 | } | 1118 | 92 | return Status::OK(); | 1119 | 92 | }, | 1120 | 92 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 0 | if (narrow_integral) { | 1122 | 0 | block.get_by_position(result).column = | 1123 | 0 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 0 | } else { | 1125 | 0 | block.get_by_position(result).column = std::move(col_to); | 1126 | 0 | } | 1127 | 0 | return Status::OK(); | 1128 | 92 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 1031 | 180 | const NullMap::value_type* null_map = nullptr) const override { | 1032 | 180 | using FromFieldType = typename FromDataType::FieldType; | 1033 | 180 | using ToFieldType = typename ToDataType::FieldType; | 1034 | 180 | const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]); | 1035 | 180 | const auto* col_from = | 1036 | 180 | check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get()); | 1037 | 180 | if (!col_from) { | 1038 | 0 | return Status::RuntimeError("Illegal column {} of first argument of function cast", | 1039 | 0 | named_from.column->get_name()); | 1040 | 0 | } | 1041 | | | 1042 | 180 | const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type); | 1043 | 180 | UInt32 from_precision = from_decimal_type.get_precision(); | 1044 | 180 | UInt32 from_scale = from_decimal_type.get_scale(); | 1045 | | | 1046 | 180 | const ColumnWithTypeAndName& named_to = block.get_by_position(result); | 1047 | 180 | const auto& to_decimal_type = assert_cast<const ToDataType&>(*named_to.type); | 1048 | 180 | UInt32 to_precision = to_decimal_type.get_precision(); | 1049 | 180 | ToDataType::check_type_precision(to_precision); | 1050 | 180 | UInt32 to_scale = to_decimal_type.get_scale(); | 1051 | 180 | ToDataType::check_type_scale(to_scale); | 1052 | | | 1053 | 180 | auto from_max_int_digit_count = from_precision - from_scale; | 1054 | 180 | auto to_max_int_digit_count = to_precision - to_scale; | 1055 | 180 | bool narrow_integral = | 1056 | 180 | (to_max_int_digit_count < from_max_int_digit_count) || | 1057 | 180 | (to_max_int_digit_count == from_max_int_digit_count && to_scale < from_scale); | 1058 | | // only in non-strict mode and may overflow, we set nullable | 1059 | 180 | bool set_nullable = (CastMode == CastModeType::NonStrictMode) && narrow_integral; | 1060 | | | 1061 | 180 | size_t size = col_from->size(); | 1062 | 180 | ColumnUInt8::MutablePtr col_null_map_to; | 1063 | 180 | NullMap::value_type* null_map_data = nullptr; | 1064 | 180 | if (narrow_integral) { | 1065 | 104 | col_null_map_to = ColumnUInt8::create(size, 0); | 1066 | 104 | null_map_data = col_null_map_to->get_data().data(); | 1067 | 104 | } | 1068 | 180 | CastParameters params; | 1069 | 180 | params.is_strict = (CastMode == CastModeType::StrictMode); | 1070 | 180 | auto col_to = ToDataType::ColumnType::create(size, to_scale); | 1071 | 180 | const auto& vec_from = col_from->get_data(); | 1072 | 180 | const auto* vec_from_data = vec_from.data(); | 1073 | 180 | auto& vec_to = col_to->get_data(); | 1074 | 180 | auto* vec_to_data = vec_to.data(); | 1075 | | | 1076 | 180 | using MaxFieldType = | 1077 | 180 | std::conditional_t<(sizeof(FromFieldType) == sizeof(ToFieldType)) && | 1078 | 180 | (std::is_same_v<ToFieldType, Decimal128V3> || | 1079 | 180 | std::is_same_v<FromFieldType, Decimal128V3>), | 1080 | 180 | Decimal128V3, | 1081 | 180 | std::conditional_t<(sizeof(FromFieldType) > sizeof(ToFieldType)), | 1082 | 180 | FromFieldType, ToFieldType>>; | 1083 | 180 | using MaxNativeType = typename MaxFieldType::NativeType; | 1084 | | | 1085 | 180 | UInt32 to_max_digits = NumberTraits::max_ascii_len<typename ToFieldType::NativeType>(); | 1086 | 180 | bool multiply_may_overflow = false; | 1087 | 180 | if (to_scale > from_scale) { | 1088 | 86 | multiply_may_overflow = (from_precision + to_scale - from_scale) >= to_max_digits; | 1089 | 86 | } | 1090 | | | 1091 | 180 | typename ToFieldType::NativeType max_result = | 1092 | 180 | DataTypeDecimal<ToFieldType::PType>::get_max_digits_number(to_precision); | 1093 | 180 | typename ToFieldType::NativeType min_result = -max_result; | 1094 | | | 1095 | 180 | MaxNativeType multiplier {}; | 1096 | 180 | if (from_scale < to_scale) { | 1097 | 86 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(to_scale - | 1098 | 86 | from_scale); | 1099 | 94 | } else if (from_scale > to_scale) { | 1100 | 68 | multiplier = DataTypeDecimal<MaxFieldType::PType>::get_scale_multiplier(from_scale - | 1101 | 68 | to_scale); | 1102 | 68 | } | 1103 | 180 | RETURN_IF_ERROR(std::visit( | 1104 | 180 | [&](auto multiply_may_overflow, auto narrow_integral) { | 1105 | 180 | for (size_t i = 0; i < size; i++) { | 1106 | 180 | if (!CastToDecimal::_from_decimal<FromFieldType, ToFieldType, | 1107 | 180 | multiply_may_overflow, narrow_integral>( | 1108 | 180 | vec_from_data[i], from_precision, from_scale, vec_to_data[i], | 1109 | 180 | to_precision, to_scale, min_result, max_result, multiplier, | 1110 | 180 | params)) { | 1111 | 180 | if (set_nullable) { | 1112 | 180 | null_map_data[i] = 1; | 1113 | 180 | } else { | 1114 | 180 | return params.status; | 1115 | 180 | } | 1116 | 180 | } | 1117 | 180 | } | 1118 | 180 | return Status::OK(); | 1119 | 180 | }, | 1120 | 180 | make_bool_variant(multiply_may_overflow), make_bool_variant(narrow_integral))); | 1121 | 180 | if (narrow_integral) { | 1122 | 104 | block.get_by_position(result).column = | 1123 | 104 | ColumnNullable::create(std::move(col_to), std::move(col_null_map_to)); | 1124 | 104 | } else { | 1125 | 76 | block.get_by_position(result).column = std::move(col_to); | 1126 | 76 | } | 1127 | 180 | return Status::OK(); | 1128 | 180 | } |
|
1129 | | }; |
1130 | | } // namespace doris |