|
55 | 55 | namespace doris { |
56 | 56 | #include "common/compile_check_begin.h" |
57 | 57 |
|
58 | | -template <PrimitiveType primitive_type, class T> |
59 | | -std::string cast_to_string(T value, int scale) { |
60 | | - if constexpr (primitive_type == TYPE_DECIMAL32) { |
61 | | - return ((vectorized::Decimal<int32_t>)value).to_string(scale); |
62 | | - } else if constexpr (primitive_type == TYPE_DECIMAL64) { |
63 | | - return ((vectorized::Decimal<int64_t>)value).to_string(scale); |
64 | | - } else if constexpr (primitive_type == TYPE_DECIMAL128I) { |
65 | | - return ((vectorized::Decimal<int128_t>)value).to_string(scale); |
66 | | - } else if constexpr (primitive_type == TYPE_DECIMAL256) { |
67 | | - return ((vectorized::Decimal<wide::Int256>)value).to_string(scale); |
68 | | - } else if constexpr (primitive_type == TYPE_TINYINT) { |
69 | | - return std::to_string(static_cast<int>(value)); |
70 | | - } else if constexpr (primitive_type == TYPE_LARGEINT) { |
71 | | - return vectorized::int128_to_string(value); |
72 | | - } else if constexpr (primitive_type == TYPE_DATETIMEV2) { |
73 | | - auto datetimev2_val = static_cast<DateV2Value<DateTimeV2ValueType>>(value); |
74 | | - char buf[30]; |
75 | | - datetimev2_val.to_string(buf); |
76 | | - std::stringstream ss; |
77 | | - ss << buf; |
78 | | - return ss.str(); |
79 | | - } else if constexpr (primitive_type == TYPE_TIMESTAMPTZ) { |
80 | | - auto timestamptz_val = static_cast<TimestampTzValue>(value); |
81 | | - return timestamptz_val.to_string(cctz::utc_time_zone(), scale); |
82 | | - } else if constexpr (primitive_type == TYPE_TIMEV2) { |
83 | | - return TimeValue::to_string(value, scale); |
84 | | - } else if constexpr (primitive_type == TYPE_IPV4) { |
85 | | - return IPv4Value::to_string(value); |
86 | | - } else if constexpr (primitive_type == TYPE_IPV6) { |
87 | | - return IPv6Value::to_string(value); |
88 | | - } else { |
89 | | - return boost::lexical_cast<std::string>(value); |
90 | | - } |
91 | | -} |
92 | | - |
93 | 58 | /** |
94 | 59 | * @brief Column's value range |
95 | 60 | **/ |
|
0 commit comments