be/src/storage/delete/delete_handler.cpp
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 | | #include "storage/delete/delete_handler.h" |
19 | | |
20 | | #include <gen_cpp/PaloInternalService_types.h> |
21 | | #include <gen_cpp/olap_file.pb.h> |
22 | | #include <thrift/protocol/TDebugProtocol.h> |
23 | | |
24 | | #include <string> |
25 | | #include <vector> |
26 | | |
27 | | #include "common/config.h" |
28 | | #include "common/logging.h" |
29 | | #include "common/status.h" |
30 | | #include "exprs/function/cast/cast_parameters.h" |
31 | | #include "exprs/function/cast/cast_to_boolean.h" |
32 | | #include "exprs/function/cast/cast_to_date_or_datetime_impl.hpp" |
33 | | #include "exprs/function/cast/cast_to_datetimev2_impl.hpp" |
34 | | #include "exprs/function/cast/cast_to_datev2_impl.hpp" |
35 | | #include "exprs/function/cast/cast_to_decimal.h" |
36 | | #include "exprs/function/cast/cast_to_float.h" |
37 | | #include "exprs/function/cast/cast_to_int.h" |
38 | | #include "exprs/function/cast/cast_to_ip.h" |
39 | | #include "storage/olap_common.h" |
40 | | #include "storage/predicate/block_column_predicate.h" |
41 | | #include "storage/predicate/predicate_creator.h" |
42 | | #include "storage/tablet/tablet_schema.h" |
43 | | #include "storage/utils.h" |
44 | | #include "util/debug_points.h" |
45 | | |
46 | | using apache::thrift::ThriftDebugString; |
47 | | using std::vector; |
48 | | using std::string; |
49 | | |
50 | | using ::google::protobuf::RepeatedPtrField; |
51 | | |
52 | | namespace doris { |
53 | | |
54 | | template <PrimitiveType PType> |
55 | | Status convert(const DataTypePtr& data_type, const std::string& str, Arena& arena, |
56 | 7.91k | typename PrimitiveTypeTraits<PType>::CppType& res) { |
57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || |
58 | 2.96k | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { |
59 | 2.96k | CastParameters parameters; |
60 | 2.96k | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { |
61 | 2 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
62 | 2 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
63 | 2 | str); |
64 | 2 | } |
65 | 2.96k | return Status::OK(); |
66 | 2.96k | } |
67 | 0 | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { |
68 | 0 | CastParameters parameters; |
69 | 0 | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { |
70 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
71 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
72 | 0 | str); |
73 | 0 | } |
74 | 0 | return Status::OK(); |
75 | 0 | } |
76 | 21 | if constexpr (PType == TYPE_DATE) { |
77 | 21 | CastParameters parameters; |
78 | 21 | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, |
79 | 21 | parameters)) { |
80 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
81 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
82 | 0 | str); |
83 | 0 | } |
84 | 21 | return Status::OK(); |
85 | 21 | } |
86 | 19 | if constexpr (PType == TYPE_DATETIME) { |
87 | 19 | CastParameters parameters; |
88 | 19 | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, |
89 | 19 | parameters)) { |
90 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
91 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
92 | 0 | str); |
93 | 0 | } |
94 | 19 | return Status::OK(); |
95 | 19 | } |
96 | 84 | if constexpr (PType == TYPE_DATEV2) { |
97 | 84 | CastParameters parameters; |
98 | 84 | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { |
99 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
100 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
101 | 0 | str); |
102 | 0 | } |
103 | 84 | return Status::OK(); |
104 | 84 | } |
105 | 103 | if constexpr (PType == TYPE_DATETIMEV2) { |
106 | 103 | CastParameters parameters; |
107 | 103 | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, |
108 | 103 | data_type->get_scale(), parameters)) { |
109 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
110 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
111 | 0 | str); |
112 | 0 | } |
113 | 103 | return Status::OK(); |
114 | 103 | } |
115 | 4.17k | if constexpr (PType == TYPE_TIMESTAMPTZ) { |
116 | 4.17k | CastParameters parameters; |
117 | 4.17k | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, |
118 | 4.17k | data_type->get_scale())) { |
119 | 5 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
120 | 5 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
121 | 5 | str); |
122 | 5 | } |
123 | 4.16k | return Status::OK(); |
124 | 4.17k | } |
125 | 8 | if constexpr (PType == TYPE_CHAR) { |
126 | 8 | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); |
127 | 8 | res = {str.data(), str.size()}; |
128 | 8 | if (target > str.size()) { |
129 | 2 | char* buffer = arena.alloc(target); |
130 | 2 | memset(buffer, 0, target); |
131 | 2 | memcpy(buffer, str.data(), str.size()); |
132 | 2 | res = {buffer, target}; |
133 | 2 | } |
134 | 8 | return Status::OK(); |
135 | 8 | } |
136 | 415 | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { |
137 | 415 | char* buffer = arena.alloc(str.size()); |
138 | 415 | memcpy(buffer, str.data(), str.size()); |
139 | 415 | res = {buffer, str.size()}; |
140 | 415 | return Status::OK(); |
141 | 415 | } |
142 | 9 | if constexpr (PType == TYPE_BOOLEAN) { |
143 | 9 | CastParameters parameters; |
144 | 9 | UInt8 tmp; |
145 | 9 | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { |
146 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
147 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
148 | 0 | str); |
149 | 0 | } |
150 | 9 | res = tmp != 0; |
151 | 9 | return Status::OK(); |
152 | 9 | } |
153 | 9 | if constexpr (PType == TYPE_IPV4) { |
154 | 9 | CastParameters parameters; |
155 | 9 | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { |
156 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
157 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
158 | 0 | str); |
159 | 0 | } |
160 | 9 | return Status::OK(); |
161 | 9 | } |
162 | 52 | if constexpr (PType == TYPE_IPV6) { |
163 | 52 | CastParameters parameters; |
164 | 52 | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { |
165 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
166 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
167 | 0 | str); |
168 | 0 | } |
169 | 52 | return Status::OK(); |
170 | 52 | } |
171 | 24 | if constexpr (PType == TYPE_DECIMALV2) { |
172 | 24 | CastParameters parameters; |
173 | 24 | Decimal128V2 tmp; |
174 | 24 | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), |
175 | 24 | data_type->get_scale(), parameters)) { |
176 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
177 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
178 | 0 | str); |
179 | 0 | } |
180 | 24 | res = DecimalV2Value(tmp.value); |
181 | 24 | return Status::OK(); |
182 | 37 | } else if constexpr (is_decimal(PType)) { |
183 | 37 | CastParameters parameters; |
184 | 37 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), |
185 | 37 | data_type->get_scale(), parameters)) { |
186 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
187 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), |
188 | 0 | str); |
189 | 0 | } |
190 | 37 | return Status::OK(); |
191 | 37 | } |
192 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
193 | 7.91k | "unsupported data type in delete handler. type={}", |
194 | 7.91k | type_to_string(data_type->get_primitive_type())); |
195 | 7.91k | } _ZN5doris7convertILNS_13PrimitiveTypeE3EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 45 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | 45 | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | 45 | CastParameters parameters; | 60 | 45 | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | 2 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | 2 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | 2 | str); | 64 | 2 | } | 65 | 43 | return Status::OK(); | 66 | 45 | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 45 | } else if constexpr (is_decimal(PType)) { | 183 | 45 | CastParameters parameters; | 184 | 45 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 45 | data_type->get_scale(), parameters)) { | 186 | 45 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 45 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 45 | str); | 189 | 45 | } | 190 | 45 | return Status::OK(); | 191 | 45 | } | 192 | 45 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 45 | "unsupported data type in delete handler. type={}", | 194 | 45 | type_to_string(data_type->get_primitive_type())); | 195 | 45 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE4EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 18 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | 18 | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | 18 | CastParameters parameters; | 60 | 18 | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | 0 | str); | 64 | 0 | } | 65 | 18 | return Status::OK(); | 66 | 18 | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 18 | } else if constexpr (is_decimal(PType)) { | 183 | 18 | CastParameters parameters; | 184 | 18 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 18 | data_type->get_scale(), parameters)) { | 186 | 18 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 18 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 18 | str); | 189 | 18 | } | 190 | 18 | return Status::OK(); | 191 | 18 | } | 192 | 18 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 18 | "unsupported data type in delete handler. type={}", | 194 | 18 | type_to_string(data_type->get_primitive_type())); | 195 | 18 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE5EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 2.31k | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | 2.31k | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | 2.31k | CastParameters parameters; | 60 | 2.31k | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | 0 | str); | 64 | 0 | } | 65 | 2.31k | return Status::OK(); | 66 | 2.31k | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 2.31k | } else if constexpr (is_decimal(PType)) { | 183 | 2.31k | CastParameters parameters; | 184 | 2.31k | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 2.31k | data_type->get_scale(), parameters)) { | 186 | 2.31k | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 2.31k | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 2.31k | str); | 189 | 2.31k | } | 190 | 2.31k | return Status::OK(); | 191 | 2.31k | } | 192 | 2.31k | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 2.31k | "unsupported data type in delete handler. type={}", | 194 | 2.31k | type_to_string(data_type->get_primitive_type())); | 195 | 2.31k | } |
_ZN5doris7convertILNS_13PrimitiveTypeE6EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 169 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | 169 | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | 169 | CastParameters parameters; | 60 | 169 | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | 0 | str); | 64 | 0 | } | 65 | 169 | return Status::OK(); | 66 | 169 | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 169 | } else if constexpr (is_decimal(PType)) { | 183 | 169 | CastParameters parameters; | 184 | 169 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 169 | data_type->get_scale(), parameters)) { | 186 | 169 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 169 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 169 | str); | 189 | 169 | } | 190 | 169 | return Status::OK(); | 191 | 169 | } | 192 | 169 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 169 | "unsupported data type in delete handler. type={}", | 194 | 169 | type_to_string(data_type->get_primitive_type())); | 195 | 169 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE7EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 421 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | 421 | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | 421 | CastParameters parameters; | 60 | 421 | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | 0 | str); | 64 | 0 | } | 65 | 421 | return Status::OK(); | 66 | 421 | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 421 | } else if constexpr (is_decimal(PType)) { | 183 | 421 | CastParameters parameters; | 184 | 421 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 421 | data_type->get_scale(), parameters)) { | 186 | 421 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 421 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 421 | str); | 189 | 421 | } | 190 | 421 | return Status::OK(); | 191 | 421 | } | 192 | 421 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 421 | "unsupported data type in delete handler. type={}", | 194 | 421 | type_to_string(data_type->get_primitive_type())); | 195 | 421 | } |
Unexecuted instantiation: _ZN5doris7convertILNS_13PrimitiveTypeE8EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Unexecuted instantiation: _ZN5doris7convertILNS_13PrimitiveTypeE9EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE _ZN5doris7convertILNS_13PrimitiveTypeE11EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 21 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | 21 | if constexpr (PType == TYPE_DATE) { | 77 | 21 | CastParameters parameters; | 78 | 21 | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | 21 | parameters)) { | 80 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | 0 | str); | 83 | 0 | } | 84 | 21 | return Status::OK(); | 85 | 21 | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 21 | } else if constexpr (is_decimal(PType)) { | 183 | 21 | CastParameters parameters; | 184 | 21 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 21 | data_type->get_scale(), parameters)) { | 186 | 21 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 21 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 21 | str); | 189 | 21 | } | 190 | 21 | return Status::OK(); | 191 | 21 | } | 192 | 21 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 21 | "unsupported data type in delete handler. type={}", | 194 | 21 | type_to_string(data_type->get_primitive_type())); | 195 | 21 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE12EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 19 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | 19 | if constexpr (PType == TYPE_DATETIME) { | 87 | 19 | CastParameters parameters; | 88 | 19 | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | 19 | parameters)) { | 90 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | 0 | str); | 93 | 0 | } | 94 | 19 | return Status::OK(); | 95 | 19 | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 19 | } else if constexpr (is_decimal(PType)) { | 183 | 19 | CastParameters parameters; | 184 | 19 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 19 | data_type->get_scale(), parameters)) { | 186 | 19 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 19 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 19 | str); | 189 | 19 | } | 190 | 19 | return Status::OK(); | 191 | 19 | } | 192 | 19 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 19 | "unsupported data type in delete handler. type={}", | 194 | 19 | type_to_string(data_type->get_primitive_type())); | 195 | 19 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE25EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 84 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | 84 | if constexpr (PType == TYPE_DATEV2) { | 97 | 84 | CastParameters parameters; | 98 | 84 | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | 0 | str); | 102 | 0 | } | 103 | 84 | return Status::OK(); | 104 | 84 | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 84 | } else if constexpr (is_decimal(PType)) { | 183 | 84 | CastParameters parameters; | 184 | 84 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 84 | data_type->get_scale(), parameters)) { | 186 | 84 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 84 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 84 | str); | 189 | 84 | } | 190 | 84 | return Status::OK(); | 191 | 84 | } | 192 | 84 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 84 | "unsupported data type in delete handler. type={}", | 194 | 84 | type_to_string(data_type->get_primitive_type())); | 195 | 84 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE26EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 103 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | 103 | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | 103 | CastParameters parameters; | 107 | 103 | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | 103 | data_type->get_scale(), parameters)) { | 109 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | 0 | str); | 112 | 0 | } | 113 | 103 | return Status::OK(); | 114 | 103 | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 103 | } else if constexpr (is_decimal(PType)) { | 183 | 103 | CastParameters parameters; | 184 | 103 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 103 | data_type->get_scale(), parameters)) { | 186 | 103 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 103 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 103 | str); | 189 | 103 | } | 190 | 103 | return Status::OK(); | 191 | 103 | } | 192 | 103 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 103 | "unsupported data type in delete handler. type={}", | 194 | 103 | type_to_string(data_type->get_primitive_type())); | 195 | 103 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE42EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 4.17k | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | 4.17k | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | 4.17k | CastParameters parameters; | 117 | 4.17k | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | 4.17k | data_type->get_scale())) { | 119 | 5 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | 5 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | 5 | str); | 122 | 5 | } | 123 | 4.16k | return Status::OK(); | 124 | 4.17k | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 4.17k | } else if constexpr (is_decimal(PType)) { | 183 | 4.17k | CastParameters parameters; | 184 | 4.17k | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 4.17k | data_type->get_scale(), parameters)) { | 186 | 4.17k | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 4.17k | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 4.17k | str); | 189 | 4.17k | } | 190 | 4.17k | return Status::OK(); | 191 | 4.17k | } | 192 | 4.17k | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 4.17k | "unsupported data type in delete handler. type={}", | 194 | 4.17k | type_to_string(data_type->get_primitive_type())); | 195 | 4.17k | } |
_ZN5doris7convertILNS_13PrimitiveTypeE2EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 9 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | 9 | if constexpr (PType == TYPE_BOOLEAN) { | 143 | 9 | CastParameters parameters; | 144 | 9 | UInt8 tmp; | 145 | 9 | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | 0 | str); | 149 | 0 | } | 150 | 9 | res = tmp != 0; | 151 | 9 | return Status::OK(); | 152 | 9 | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 9 | } else if constexpr (is_decimal(PType)) { | 183 | 9 | CastParameters parameters; | 184 | 9 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 9 | data_type->get_scale(), parameters)) { | 186 | 9 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 9 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 9 | str); | 189 | 9 | } | 190 | 9 | return Status::OK(); | 191 | 9 | } | 192 | 9 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 9 | "unsupported data type in delete handler. type={}", | 194 | 9 | type_to_string(data_type->get_primitive_type())); | 195 | 9 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE36EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 9 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | 9 | if constexpr (PType == TYPE_IPV4) { | 154 | 9 | CastParameters parameters; | 155 | 9 | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | 0 | str); | 159 | 0 | } | 160 | 9 | return Status::OK(); | 161 | 9 | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 9 | } else if constexpr (is_decimal(PType)) { | 183 | 9 | CastParameters parameters; | 184 | 9 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 9 | data_type->get_scale(), parameters)) { | 186 | 9 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 9 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 9 | str); | 189 | 9 | } | 190 | 9 | return Status::OK(); | 191 | 9 | } | 192 | 9 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 9 | "unsupported data type in delete handler. type={}", | 194 | 9 | type_to_string(data_type->get_primitive_type())); | 195 | 9 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE37EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 52 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | 52 | if constexpr (PType == TYPE_IPV6) { | 163 | 52 | CastParameters parameters; | 164 | 52 | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | 0 | str); | 168 | 0 | } | 169 | 52 | return Status::OK(); | 170 | 52 | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 52 | } else if constexpr (is_decimal(PType)) { | 183 | 52 | CastParameters parameters; | 184 | 52 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 52 | data_type->get_scale(), parameters)) { | 186 | 52 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 52 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 52 | str); | 189 | 52 | } | 190 | 52 | return Status::OK(); | 191 | 52 | } | 192 | 52 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 52 | "unsupported data type in delete handler. type={}", | 194 | 52 | type_to_string(data_type->get_primitive_type())); | 195 | 52 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE20EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 24 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | 24 | if constexpr (PType == TYPE_DECIMALV2) { | 172 | 24 | CastParameters parameters; | 173 | 24 | Decimal128V2 tmp; | 174 | 24 | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | 24 | data_type->get_scale(), parameters)) { | 176 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | 0 | str); | 179 | 0 | } | 180 | 24 | res = DecimalV2Value(tmp.value); | 181 | 24 | return Status::OK(); | 182 | | } else if constexpr (is_decimal(PType)) { | 183 | | CastParameters parameters; | 184 | | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | | data_type->get_scale(), parameters)) { | 186 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | | str); | 189 | | } | 190 | | return Status::OK(); | 191 | | } | 192 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 24 | "unsupported data type in delete handler. type={}", | 194 | 24 | type_to_string(data_type->get_primitive_type())); | 195 | 24 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE28EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 12 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 12 | } else if constexpr (is_decimal(PType)) { | 183 | 12 | CastParameters parameters; | 184 | 12 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 12 | data_type->get_scale(), parameters)) { | 186 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 0 | str); | 189 | 0 | } | 190 | 12 | return Status::OK(); | 191 | 12 | } | 192 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 12 | "unsupported data type in delete handler. type={}", | 194 | 12 | type_to_string(data_type->get_primitive_type())); | 195 | 12 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE29EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 24 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 24 | } else if constexpr (is_decimal(PType)) { | 183 | 24 | CastParameters parameters; | 184 | 24 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 24 | data_type->get_scale(), parameters)) { | 186 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 0 | str); | 189 | 0 | } | 190 | 24 | return Status::OK(); | 191 | 24 | } | 192 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 24 | "unsupported data type in delete handler. type={}", | 194 | 24 | type_to_string(data_type->get_primitive_type())); | 195 | 24 | } |
Unexecuted instantiation: _ZN5doris7convertILNS_13PrimitiveTypeE30EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE _ZN5doris7convertILNS_13PrimitiveTypeE35EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 1 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 1 | } else if constexpr (is_decimal(PType)) { | 183 | 1 | CastParameters parameters; | 184 | 1 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 1 | data_type->get_scale(), parameters)) { | 186 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 0 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 0 | str); | 189 | 0 | } | 190 | 1 | return Status::OK(); | 191 | 1 | } | 192 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 1 | "unsupported data type in delete handler. type={}", | 194 | 1 | type_to_string(data_type->get_primitive_type())); | 195 | 1 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE15EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 8 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | 8 | if constexpr (PType == TYPE_CHAR) { | 126 | 8 | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | 8 | res = {str.data(), str.size()}; | 128 | 8 | if (target > str.size()) { | 129 | 2 | char* buffer = arena.alloc(target); | 130 | 2 | memset(buffer, 0, target); | 131 | 2 | memcpy(buffer, str.data(), str.size()); | 132 | 2 | res = {buffer, target}; | 133 | 2 | } | 134 | 8 | return Status::OK(); | 135 | 8 | } | 136 | | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | | char* buffer = arena.alloc(str.size()); | 138 | | memcpy(buffer, str.data(), str.size()); | 139 | | res = {buffer, str.size()}; | 140 | | return Status::OK(); | 141 | | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 8 | } else if constexpr (is_decimal(PType)) { | 183 | 8 | CastParameters parameters; | 184 | 8 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 8 | data_type->get_scale(), parameters)) { | 186 | 8 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 8 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 8 | str); | 189 | 8 | } | 190 | 8 | return Status::OK(); | 191 | 8 | } | 192 | 8 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 8 | "unsupported data type in delete handler. type={}", | 194 | 8 | type_to_string(data_type->get_primitive_type())); | 195 | 8 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE10EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 409 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | 409 | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | 409 | char* buffer = arena.alloc(str.size()); | 138 | 409 | memcpy(buffer, str.data(), str.size()); | 139 | 409 | res = {buffer, str.size()}; | 140 | 409 | return Status::OK(); | 141 | 409 | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 409 | } else if constexpr (is_decimal(PType)) { | 183 | 409 | CastParameters parameters; | 184 | 409 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 409 | data_type->get_scale(), parameters)) { | 186 | 409 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 409 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 409 | str); | 189 | 409 | } | 190 | 409 | return Status::OK(); | 191 | 409 | } | 192 | 409 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 409 | "unsupported data type in delete handler. type={}", | 194 | 409 | type_to_string(data_type->get_primitive_type())); | 195 | 409 | } |
_ZN5doris7convertILNS_13PrimitiveTypeE23EEENS_6StatusERKSt10shared_ptrIKNS_9IDataTypeEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArenaERNS_19PrimitiveTypeTraitsIXT_EE7CppTypeE Line | Count | Source | 56 | 6 | typename PrimitiveTypeTraits<PType>::CppType& res) { | 57 | | if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType == TYPE_INT || | 58 | | PType == TYPE_BIGINT || PType == TYPE_LARGEINT) { | 59 | | CastParameters parameters; | 60 | | if (!CastToInt::from_string<false>({str.data(), str.size()}, res, parameters)) { | 61 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 62 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 63 | | str); | 64 | | } | 65 | | return Status::OK(); | 66 | | } | 67 | | if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) { | 68 | | CastParameters parameters; | 69 | | if (!CastToFloat::from_string({str.data(), str.size()}, res, parameters)) { | 70 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 71 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 72 | | str); | 73 | | } | 74 | | return Status::OK(); | 75 | | } | 76 | | if constexpr (PType == TYPE_DATE) { | 77 | | CastParameters parameters; | 78 | | if (!CastToDateOrDatetime::from_string<false>({str.data(), str.size()}, res, nullptr, | 79 | | parameters)) { | 80 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 81 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 82 | | str); | 83 | | } | 84 | | return Status::OK(); | 85 | | } | 86 | | if constexpr (PType == TYPE_DATETIME) { | 87 | | CastParameters parameters; | 88 | | if (!CastToDateOrDatetime::from_string<true>({str.data(), str.size()}, res, nullptr, | 89 | | parameters)) { | 90 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 91 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 92 | | str); | 93 | | } | 94 | | return Status::OK(); | 95 | | } | 96 | | if constexpr (PType == TYPE_DATEV2) { | 97 | | CastParameters parameters; | 98 | | if (!CastToDateV2::from_string({str.data(), str.size()}, res, nullptr, parameters)) { | 99 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 100 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 101 | | str); | 102 | | } | 103 | | return Status::OK(); | 104 | | } | 105 | | if constexpr (PType == TYPE_DATETIMEV2) { | 106 | | CastParameters parameters; | 107 | | if (!CastToDatetimeV2::from_string({str.data(), str.size()}, res, nullptr, | 108 | | data_type->get_scale(), parameters)) { | 109 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 110 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 111 | | str); | 112 | | } | 113 | | return Status::OK(); | 114 | | } | 115 | | if constexpr (PType == TYPE_TIMESTAMPTZ) { | 116 | | CastParameters parameters; | 117 | | if (!CastToTimstampTz::from_string({str.data(), str.size()}, res, parameters, nullptr, | 118 | | data_type->get_scale())) { | 119 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 120 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 121 | | str); | 122 | | } | 123 | | return Status::OK(); | 124 | | } | 125 | | if constexpr (PType == TYPE_CHAR) { | 126 | | size_t target = assert_cast<const DataTypeString*>(remove_nullable(data_type).get())->len(); | 127 | | res = {str.data(), str.size()}; | 128 | | if (target > str.size()) { | 129 | | char* buffer = arena.alloc(target); | 130 | | memset(buffer, 0, target); | 131 | | memcpy(buffer, str.data(), str.size()); | 132 | | res = {buffer, target}; | 133 | | } | 134 | | return Status::OK(); | 135 | | } | 136 | 6 | if constexpr (PType == TYPE_STRING || PType == TYPE_VARCHAR) { | 137 | 6 | char* buffer = arena.alloc(str.size()); | 138 | 6 | memcpy(buffer, str.data(), str.size()); | 139 | 6 | res = {buffer, str.size()}; | 140 | 6 | return Status::OK(); | 141 | 6 | } | 142 | | if constexpr (PType == TYPE_BOOLEAN) { | 143 | | CastParameters parameters; | 144 | | UInt8 tmp; | 145 | | if (!CastToBool::from_string({str.data(), str.size()}, tmp, parameters)) { | 146 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 147 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 148 | | str); | 149 | | } | 150 | | res = tmp != 0; | 151 | | return Status::OK(); | 152 | | } | 153 | | if constexpr (PType == TYPE_IPV4) { | 154 | | CastParameters parameters; | 155 | | if (!CastToIPv4::from_string({str.data(), str.size()}, res, parameters)) { | 156 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 157 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 158 | | str); | 159 | | } | 160 | | return Status::OK(); | 161 | | } | 162 | | if constexpr (PType == TYPE_IPV6) { | 163 | | CastParameters parameters; | 164 | | if (!CastToIPv6::from_string({str.data(), str.size()}, res, parameters)) { | 165 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 166 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 167 | | str); | 168 | | } | 169 | | return Status::OK(); | 170 | | } | 171 | | if constexpr (PType == TYPE_DECIMALV2) { | 172 | | CastParameters parameters; | 173 | | Decimal128V2 tmp; | 174 | | if (!CastToDecimal::from_string({str.data(), str.size()}, tmp, data_type->get_precision(), | 175 | | data_type->get_scale(), parameters)) { | 176 | | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 177 | | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 178 | | str); | 179 | | } | 180 | | res = DecimalV2Value(tmp.value); | 181 | | return Status::OK(); | 182 | 6 | } else if constexpr (is_decimal(PType)) { | 183 | 6 | CastParameters parameters; | 184 | 6 | if (!CastToDecimal::from_string({str.data(), str.size()}, res, data_type->get_precision(), | 185 | 6 | data_type->get_scale(), parameters)) { | 186 | 6 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 187 | 6 | "invalid {} string. str={}", type_to_string(data_type->get_primitive_type()), | 188 | 6 | str); | 189 | 6 | } | 190 | 6 | return Status::OK(); | 191 | 6 | } | 192 | 6 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( | 193 | 6 | "unsupported data type in delete handler. type={}", | 194 | 6 | type_to_string(data_type->get_primitive_type())); | 195 | 6 | } |
|
196 | | |
197 | | #define CONVERT_CASE(PType) \ |
198 | 364 | case PType: { \ |
199 | 364 | set = build_set<PType>(); \ |
200 | 1.18k | for (const auto& s : str) { \ |
201 | 1.18k | typename PrimitiveTypeTraits<PType>::CppType tmp; \ |
202 | 1.18k | RETURN_IF_ERROR(convert<PType>(data_type, s, arena, tmp)); \ |
203 | 1.18k | set->insert(reinterpret_cast<const void*>(&tmp)); \ |
204 | 1.18k | } \ |
205 | 364 | return Status::OK(); \ |
206 | 364 | } |
207 | | Status convert(const DataTypePtr& data_type, const std::list<std::string>& str, Arena& arena, |
208 | 364 | std::shared_ptr<HybridSetBase>& set) { |
209 | 364 | switch (data_type->get_primitive_type()) { |
210 | 3 | CONVERT_CASE(TYPE_TINYINT); |
211 | 3 | CONVERT_CASE(TYPE_SMALLINT); |
212 | 105 | CONVERT_CASE(TYPE_INT); |
213 | 11 | CONVERT_CASE(TYPE_BIGINT); |
214 | 0 | CONVERT_CASE(TYPE_LARGEINT); |
215 | 0 | CONVERT_CASE(TYPE_FLOAT); |
216 | 0 | CONVERT_CASE(TYPE_DOUBLE); |
217 | 0 | CONVERT_CASE(TYPE_DATE); |
218 | 0 | CONVERT_CASE(TYPE_DATETIME); |
219 | 3 | CONVERT_CASE(TYPE_DATEV2); |
220 | 3 | CONVERT_CASE(TYPE_DATETIMEV2); |
221 | 98 | CONVERT_CASE(TYPE_TIMESTAMPTZ); |
222 | 0 | CONVERT_CASE(TYPE_BOOLEAN); |
223 | 0 | CONVERT_CASE(TYPE_IPV4); |
224 | 0 | CONVERT_CASE(TYPE_IPV6); |
225 | 6 | CONVERT_CASE(TYPE_DECIMALV2); |
226 | 0 | CONVERT_CASE(TYPE_DECIMAL32); |
227 | 3 | CONVERT_CASE(TYPE_DECIMAL64); |
228 | 0 | CONVERT_CASE(TYPE_DECIMAL128I); |
229 | 0 | CONVERT_CASE(TYPE_DECIMAL256); |
230 | 4 | CONVERT_CASE(TYPE_CHAR); |
231 | 122 | CONVERT_CASE(TYPE_VARCHAR); |
232 | 3 | CONVERT_CASE(TYPE_STRING); |
233 | 0 | default: |
234 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
235 | 0 | "unsupported data type in delete handler. type={}", |
236 | 0 | type_to_string(data_type->get_primitive_type())); |
237 | 364 | } |
238 | 0 | return Status::OK(); |
239 | 364 | } |
240 | | #undef CONVERT_CASE |
241 | | |
242 | | #define CONVERT_CASE(PType) \ |
243 | 6.73k | case PType: { \ |
244 | 6.73k | typename PrimitiveTypeTraits<PType>::CppType tmp; \ |
245 | 6.73k | RETURN_IF_ERROR(convert<PType>(type, res.value_str.front(), arena, tmp)); \ |
246 | 6.73k | v = Field::create_field<PType>(tmp); \ |
247 | 6.73k | switch (res.condition_op) { \ |
248 | 3.39k | case PredicateType::EQ: \ |
249 | 3.39k | predicate = create_comparison_predicate<PredicateType::EQ>(index, col_name, type, v, \ |
250 | 3.39k | true); \ |
251 | 3.39k | return Status::OK(); \ |
252 | 948 | case PredicateType::NE: \ |
253 | 948 | predicate = create_comparison_predicate<PredicateType::NE>(index, col_name, type, v, \ |
254 | 948 | true); \ |
255 | 948 | return Status::OK(); \ |
256 | 517 | case PredicateType::GT: \ |
257 | 517 | predicate = create_comparison_predicate<PredicateType::GT>(index, col_name, type, v, \ |
258 | 517 | true); \ |
259 | 517 | return Status::OK(); \ |
260 | 342 | case PredicateType::GE: \ |
261 | 342 | predicate = create_comparison_predicate<PredicateType::GE>(index, col_name, type, v, \ |
262 | 342 | true); \ |
263 | 342 | return Status::OK(); \ |
264 | 921 | case PredicateType::LT: \ |
265 | 921 | predicate = create_comparison_predicate<PredicateType::LT>(index, col_name, type, v, \ |
266 | 921 | true); \ |
267 | 921 | return Status::OK(); \ |
268 | 597 | case PredicateType::LE: \ |
269 | 597 | predicate = create_comparison_predicate<PredicateType::LE>(index, col_name, type, v, \ |
270 | 597 | true); \ |
271 | 597 | return Status::OK(); \ |
272 | 0 | default: \ |
273 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( \ |
274 | 0 | "invalid condition operator. operator={}", type_to_op_str(res.condition_op)); \ |
275 | 6.73k | } \ |
276 | 6.73k | } |
277 | | Status parse_to_predicate(const uint32_t index, const std::string col_name, const DataTypePtr& type, |
278 | | DeleteHandler::ConditionParseResult& res, Arena& arena, |
279 | 8.74k | std::shared_ptr<ColumnPredicate>& predicate) { |
280 | 8.74k | DCHECK_EQ(res.value_str.size(), 1); |
281 | 8.74k | if (res.condition_op == PredicateType::IS_NULL || |
282 | 8.74k | res.condition_op == PredicateType::IS_NOT_NULL) { |
283 | 528 | predicate = NullPredicate::create_shared(index, col_name, |
284 | 528 | res.condition_op == PredicateType::IS_NOT_NULL, |
285 | 528 | type->get_primitive_type()); |
286 | 528 | return Status::OK(); |
287 | 528 | } |
288 | 8.21k | Field v; |
289 | 8.21k | switch (type->get_primitive_type()) { |
290 | 64 | CONVERT_CASE(TYPE_TINYINT); |
291 | 24 | CONVERT_CASE(TYPE_SMALLINT); |
292 | 3.97k | CONVERT_CASE(TYPE_INT); |
293 | 284 | CONVERT_CASE(TYPE_BIGINT); |
294 | 842 | CONVERT_CASE(TYPE_LARGEINT); |
295 | 0 | CONVERT_CASE(TYPE_FLOAT); |
296 | 0 | CONVERT_CASE(TYPE_DOUBLE); |
297 | 42 | CONVERT_CASE(TYPE_DATE); |
298 | 38 | CONVERT_CASE(TYPE_DATETIME); |
299 | 156 | CONVERT_CASE(TYPE_DATEV2); |
300 | 194 | CONVERT_CASE(TYPE_DATETIMEV2); |
301 | 7.64k | CONVERT_CASE(TYPE_TIMESTAMPTZ); |
302 | 18 | CONVERT_CASE(TYPE_BOOLEAN); |
303 | 18 | CONVERT_CASE(TYPE_IPV4); |
304 | 104 | CONVERT_CASE(TYPE_IPV6); |
305 | 0 | CONVERT_CASE(TYPE_DECIMALV2); |
306 | 24 | CONVERT_CASE(TYPE_DECIMAL32); |
307 | 36 | CONVERT_CASE(TYPE_DECIMAL64); |
308 | 0 | CONVERT_CASE(TYPE_DECIMAL128I); |
309 | 2 | CONVERT_CASE(TYPE_DECIMAL256); |
310 | 12 | case TYPE_CHAR: |
311 | 1.26k | case TYPE_VARCHAR: |
312 | 1.46k | case TYPE_STRING: { |
313 | 1.46k | v = Field::create_field<TYPE_STRING>(res.value_str.front()); |
314 | 1.46k | switch (res.condition_op) { |
315 | 1.41k | case PredicateType::EQ: |
316 | 1.41k | predicate = |
317 | 1.41k | create_comparison_predicate<PredicateType::EQ>(index, col_name, type, v, true); |
318 | 1.41k | return Status::OK(); |
319 | 9 | case PredicateType::NE: |
320 | 9 | predicate = |
321 | 9 | create_comparison_predicate<PredicateType::NE>(index, col_name, type, v, true); |
322 | 9 | return Status::OK(); |
323 | 0 | case PredicateType::GT: |
324 | 0 | predicate = |
325 | 0 | create_comparison_predicate<PredicateType::GT>(index, col_name, type, v, true); |
326 | 0 | return Status::OK(); |
327 | 9 | case PredicateType::GE: |
328 | 9 | predicate = |
329 | 9 | create_comparison_predicate<PredicateType::GE>(index, col_name, type, v, true); |
330 | 9 | return Status::OK(); |
331 | 21 | case PredicateType::LT: |
332 | 21 | predicate = |
333 | 21 | create_comparison_predicate<PredicateType::LT>(index, col_name, type, v, true); |
334 | 21 | return Status::OK(); |
335 | 9 | case PredicateType::LE: |
336 | 9 | predicate = |
337 | 9 | create_comparison_predicate<PredicateType::LE>(index, col_name, type, v, true); |
338 | 9 | return Status::OK(); |
339 | 0 | default: |
340 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
341 | 0 | "invalid condition operator. operator={}", type_to_op_str(res.condition_op)); |
342 | 1.46k | } |
343 | 0 | break; |
344 | 1.46k | } |
345 | 0 | default: |
346 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
347 | 0 | "unsupported data type in delete handler. type={}", |
348 | 0 | type_to_string(type->get_primitive_type())); |
349 | 8.21k | } |
350 | 0 | return Status::OK(); |
351 | 8.21k | #undef CONVERT_CASE |
352 | 8.21k | } |
353 | | |
354 | | Status parse_to_in_predicate(const uint32_t index, const std::string& col_name, |
355 | | const DataTypePtr& type, DeleteHandler::ConditionParseResult& res, |
356 | 364 | Arena& arena, std::shared_ptr<ColumnPredicate>& predicate) { |
357 | 364 | DCHECK_GT(res.value_str.size(), 1); |
358 | 364 | switch (res.condition_op) { |
359 | 309 | case PredicateType::IN_LIST: { |
360 | 309 | std::shared_ptr<HybridSetBase> set; |
361 | 309 | RETURN_IF_ERROR(convert(type, res.value_str, arena, set)); |
362 | 309 | predicate = |
363 | 309 | create_in_list_predicate<PredicateType::IN_LIST>(index, col_name, type, set, true); |
364 | 309 | break; |
365 | 309 | } |
366 | 55 | case PredicateType::NOT_IN_LIST: { |
367 | 55 | std::shared_ptr<HybridSetBase> set; |
368 | 55 | RETURN_IF_ERROR(convert(type, res.value_str, arena, set)); |
369 | 55 | predicate = create_in_list_predicate<PredicateType::NOT_IN_LIST>(index, col_name, type, set, |
370 | 55 | true); |
371 | 55 | break; |
372 | 55 | } |
373 | 0 | default: |
374 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>("invalid condition operator. operator={}", |
375 | 0 | type_to_op_str(res.condition_op)); |
376 | 364 | } |
377 | 364 | return Status::OK(); |
378 | 364 | } |
379 | | |
380 | | // construct sub condition from TCondition |
381 | 3.16k | std::string construct_sub_predicate(const TCondition& condition) { |
382 | 3.16k | string op = condition.condition_op; |
383 | 3.16k | if (op == "<") { |
384 | 332 | op += "<"; |
385 | 2.83k | } else if (op == ">") { |
386 | 233 | op += ">"; |
387 | 233 | } |
388 | 3.16k | string condition_str; |
389 | 3.16k | if ("IS" == op) { |
390 | | // ATTN: tricky! Surround IS with spaces to make it "special" |
391 | 402 | condition_str = condition.column_name + " IS " + condition.condition_values[0]; |
392 | 2.76k | } else { // multi-elements IN expr has been processed with InPredicatePB |
393 | 2.76k | if (op == "*=") { |
394 | 2 | op = "="; |
395 | 2.75k | } else if (op == "!*=") { |
396 | 2 | op = "!="; |
397 | 2 | } |
398 | 2.76k | condition_str = condition.column_name + op + "'" + condition.condition_values[0] + "'"; |
399 | 2.76k | } |
400 | 3.16k | return condition_str; |
401 | 3.16k | } |
402 | | |
403 | | // make operators from FE adaptive to BE |
404 | 3.17k | std::string trans_op(const std::string& opt) { |
405 | 3.17k | std::string op = string(opt); |
406 | 3.17k | if (op == "<") { |
407 | 332 | op += "<"; |
408 | 2.84k | } else if (op == ">") { |
409 | 233 | op += ">"; |
410 | 233 | } |
411 | 3.17k | if ("IS" != op) { |
412 | 2.78k | if (op == "*=") { |
413 | 2 | op = "="; |
414 | 2.78k | } else if (op == "!*=") { |
415 | 2 | op = "!="; |
416 | 2 | } |
417 | 2.78k | } |
418 | 3.17k | return op; |
419 | 3.17k | } |
420 | | |
421 | | Status DeleteHandler::generate_delete_predicate(const TabletSchema& schema, |
422 | | const std::vector<TCondition>& conditions, |
423 | 3.32k | DeletePredicatePB* del_pred) { |
424 | 3.32k | DBUG_EXECUTE_IF("DeleteHandler::generate_delete_predicate.inject_failure", { |
425 | 3.32k | return Status::Error<false>(dp->param<int>("error_code"), |
426 | 3.32k | dp->param<std::string>("error_msg")); |
427 | 3.32k | }) |
428 | 3.32k | if (conditions.empty()) { |
429 | 1 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
430 | 1 | "invalid parameters for store_cond. condition_size={}", conditions.size()); |
431 | 1 | } |
432 | | |
433 | | // Check whether the delete condition meets the requirements |
434 | 3.45k | for (const TCondition& condition : conditions) { |
435 | 3.45k | RETURN_IF_ERROR(check_condition_valid(schema, condition)); |
436 | 3.45k | } |
437 | | |
438 | | // Store delete condition |
439 | 3.41k | for (const TCondition& condition : conditions) { |
440 | 3.41k | if (condition.condition_values.size() > 1) { |
441 | 195 | InPredicatePB* in_pred = del_pred->add_in_predicates(); |
442 | 195 | if (condition.__isset.column_unique_id) { |
443 | 191 | in_pred->set_column_unique_id(condition.column_unique_id); |
444 | 191 | } |
445 | 195 | in_pred->set_column_name(condition.column_name); |
446 | 195 | bool is_not_in = condition.condition_op == "!*="; |
447 | 195 | in_pred->set_is_not_in(is_not_in); |
448 | 623 | for (const auto& condition_value : condition.condition_values) { |
449 | 623 | in_pred->add_values(condition_value); |
450 | 623 | } |
451 | | |
452 | 195 | LOG(INFO) << "store one sub-delete condition. condition name=" << in_pred->column_name() |
453 | 195 | << "condition size=" << in_pred->values().size(); |
454 | 3.22k | } else { |
455 | | // write sub predicate v1 for compactbility |
456 | 3.22k | std::string condition_str = construct_sub_predicate(condition); |
457 | 3.22k | VLOG_NOTICE << __PRETTY_FUNCTION__ << " condition_str: " << condition_str; |
458 | 3.22k | del_pred->add_sub_predicates(condition_str); |
459 | 3.22k | DeleteSubPredicatePB* sub_predicate = del_pred->add_sub_predicates_v2(); |
460 | 3.22k | if (condition.__isset.column_unique_id) { |
461 | | // only light schema change capable table set this field |
462 | 3.11k | sub_predicate->set_column_unique_id(condition.column_unique_id); |
463 | 3.11k | } else { |
464 | 106 | try { |
465 | 106 | [[maybe_unused]] auto parsed_cond = parse_condition(condition_str); |
466 | 106 | } catch (const Exception& e) { |
467 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>( |
468 | 0 | "failed to parse condition_str, condition={}, error={}", |
469 | 0 | ThriftDebugString(condition), e.to_string()); |
470 | 0 | } |
471 | 106 | } |
472 | | |
473 | 3.21k | sub_predicate->set_column_name(condition.column_name); |
474 | 3.21k | sub_predicate->set_op(trans_op(condition.condition_op)); |
475 | 3.21k | sub_predicate->set_cond_value(condition.condition_values[0]); |
476 | 3.21k | LOG(INFO) << "store one sub-delete condition. condition=" |
477 | 3.21k | << fmt::format(" {} {} {}", condition.column_name, condition.condition_op, |
478 | 3.21k | condition.condition_values[0]); |
479 | 3.21k | } |
480 | 3.41k | } |
481 | 3.29k | del_pred->set_version(-1); |
482 | | |
483 | 3.29k | return Status::OK(); |
484 | 3.29k | } |
485 | | |
486 | | Status DeleteHandler::convert_to_sub_pred_v2(DeletePredicatePB* delete_pred, |
487 | 0 | TabletSchemaSPtr schema) { |
488 | 0 | if (!delete_pred->sub_predicates().empty() && delete_pred->sub_predicates_v2().empty()) { |
489 | 0 | for (const auto& condition_str : delete_pred->sub_predicates()) { |
490 | 0 | auto* sub_pred = delete_pred->add_sub_predicates_v2(); |
491 | 0 | auto condition = parse_condition(condition_str); |
492 | 0 | const auto& column = *DORIS_TRY(schema->column(condition.column_name)); |
493 | 0 | sub_pred->set_column_unique_id(column.unique_id()); |
494 | 0 | sub_pred->set_column_name(condition.column_name); |
495 | 0 | sub_pred->set_op(type_to_op_str(condition.condition_op)); |
496 | 0 | sub_pred->set_cond_value(condition.value_str.front()); |
497 | 0 | } |
498 | 0 | } |
499 | | |
500 | 0 | auto* in_pred_list = delete_pred->mutable_in_predicates(); |
501 | 0 | for (auto& in_pred : *in_pred_list) { |
502 | 0 | const auto& column = *DORIS_TRY(schema->column(in_pred.column_name())); |
503 | 0 | in_pred.set_column_unique_id(column.unique_id()); |
504 | 0 | } |
505 | 0 | return Status::OK(); |
506 | 0 | } |
507 | | |
508 | | bool DeleteHandler::is_condition_value_valid(const TabletColumn& column, |
509 | | const std::string& condition_op, |
510 | 3.84k | const string& value_str) { |
511 | 3.84k | if ("IS" == condition_op && ("NULL" == value_str || "NOT NULL" == value_str)) { |
512 | 407 | return true; |
513 | 407 | } |
514 | | |
515 | 3.44k | FieldType field_type = column.type(); |
516 | 3.44k | switch (field_type) { |
517 | 25 | case FieldType::OLAP_FIELD_TYPE_TINYINT: |
518 | 25 | return valid_signed_number<int8_t>(value_str); |
519 | 17 | case FieldType::OLAP_FIELD_TYPE_SMALLINT: |
520 | 17 | return valid_signed_number<int16_t>(value_str); |
521 | 834 | case FieldType::OLAP_FIELD_TYPE_INT: |
522 | 834 | return valid_signed_number<int32_t>(value_str); |
523 | 59 | case FieldType::OLAP_FIELD_TYPE_BIGINT: |
524 | 59 | return valid_signed_number<int64_t>(value_str); |
525 | 161 | case FieldType::OLAP_FIELD_TYPE_LARGEINT: |
526 | 161 | return valid_signed_number<int128_t>(value_str); |
527 | 0 | case FieldType::OLAP_FIELD_TYPE_UNSIGNED_TINYINT: |
528 | 0 | return valid_unsigned_number<uint8_t>(value_str); |
529 | 0 | case FieldType::OLAP_FIELD_TYPE_UNSIGNED_SMALLINT: |
530 | 0 | return valid_unsigned_number<uint16_t>(value_str); |
531 | 0 | case FieldType::OLAP_FIELD_TYPE_UNSIGNED_INT: |
532 | 0 | return valid_unsigned_number<uint32_t>(value_str); |
533 | 0 | case FieldType::OLAP_FIELD_TYPE_UNSIGNED_BIGINT: |
534 | 0 | return valid_unsigned_number<uint64_t>(value_str); |
535 | 15 | case FieldType::OLAP_FIELD_TYPE_DECIMAL: |
536 | 15 | return valid_decimal(value_str, column.precision(), column.frac()); |
537 | 8 | case FieldType::OLAP_FIELD_TYPE_DECIMAL32: |
538 | 8 | return valid_decimal(value_str, column.precision(), column.frac()); |
539 | 10 | case FieldType::OLAP_FIELD_TYPE_DECIMAL64: |
540 | 10 | return valid_decimal(value_str, column.precision(), column.frac()); |
541 | 0 | case FieldType::OLAP_FIELD_TYPE_DECIMAL128I: |
542 | 0 | return valid_decimal(value_str, column.precision(), column.frac()); |
543 | 1 | case FieldType::OLAP_FIELD_TYPE_DECIMAL256: |
544 | 1 | return valid_decimal(value_str, column.precision(), column.frac()); |
545 | 11 | case FieldType::OLAP_FIELD_TYPE_CHAR: |
546 | 232 | case FieldType::OLAP_FIELD_TYPE_VARCHAR: |
547 | 232 | return value_str.size() <= column.length(); |
548 | 45 | case FieldType::OLAP_FIELD_TYPE_STRING: |
549 | 45 | return value_str.size() <= config::string_type_length_soft_limit_bytes; |
550 | 14 | case FieldType::OLAP_FIELD_TYPE_DATE: |
551 | 29 | case FieldType::OLAP_FIELD_TYPE_DATETIME: |
552 | 62 | case FieldType::OLAP_FIELD_TYPE_DATEV2: |
553 | 97 | case FieldType::OLAP_FIELD_TYPE_DATETIMEV2: |
554 | 2.00k | case FieldType::OLAP_FIELD_TYPE_TIMESTAMPTZ: |
555 | 2.00k | return valid_datetime(value_str, column.frac()); |
556 | 5 | case FieldType::OLAP_FIELD_TYPE_BOOL: |
557 | 5 | return valid_bool(value_str); |
558 | 9 | case FieldType::OLAP_FIELD_TYPE_IPV4: |
559 | 9 | return valid_ipv4(value_str); |
560 | 35 | case FieldType::OLAP_FIELD_TYPE_IPV6: |
561 | 35 | return valid_ipv6(value_str); |
562 | 0 | default: |
563 | 0 | LOG(WARNING) << "unknown field type. [type=" << int(field_type) << "]"; |
564 | 3.44k | } |
565 | 0 | return false; |
566 | 3.44k | } |
567 | | |
568 | 3.43k | Status DeleteHandler::check_condition_valid(const TabletSchema& schema, const TCondition& cond) { |
569 | | // Check whether the column exists |
570 | 3.43k | int32_t field_index = schema.field_index(cond.column_name); |
571 | 3.43k | if (field_index < 0) { |
572 | 1 | return Status::Error<ErrorCode::INVALID_ARGUMENT>("field is not existent. [field_index={}]", |
573 | 1 | field_index); |
574 | 1 | } |
575 | | |
576 | | // Delete condition should only applied on key columns or duplicate key table, and |
577 | | // the condition column type should not be float or double. |
578 | 3.42k | const TabletColumn& column = schema.column(field_index); |
579 | | |
580 | 3.42k | if (column.type() == FieldType::OLAP_FIELD_TYPE_DOUBLE || |
581 | 3.43k | column.type() == FieldType::OLAP_FIELD_TYPE_FLOAT) { |
582 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>("data type is float or double."); |
583 | 0 | } |
584 | | |
585 | | // Check operator and operands size are matched. |
586 | 3.42k | if ("*=" != cond.condition_op && "!*=" != cond.condition_op && |
587 | 3.42k | cond.condition_values.size() != 1) { |
588 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>("invalid condition value size. [size={}]", |
589 | 0 | cond.condition_values.size()); |
590 | 0 | } |
591 | | |
592 | | // Check each operand is valid |
593 | 3.86k | for (const auto& condition_value : cond.condition_values) { |
594 | 3.86k | if (!is_condition_value_valid(column, cond.condition_op, condition_value)) { |
595 | 29 | return Status::Error<ErrorCode::INVALID_ARGUMENT>("invalid condition value. [value={}]", |
596 | 29 | condition_value); |
597 | 29 | } |
598 | 3.86k | } |
599 | | |
600 | 3.40k | if (!cond.__isset.column_unique_id) { |
601 | 105 | LOG(WARNING) << "column=" << cond.column_name |
602 | 105 | << " in predicate does not have uid, table id=" << schema.table_id(); |
603 | | // TODO(tsy): make it fail here after FE forbidding hard-link-schema-change |
604 | 105 | return Status::OK(); |
605 | 105 | } |
606 | 3.29k | if (schema.field_index(cond.column_unique_id) == -1) { |
607 | 0 | const auto& err_msg = |
608 | 0 | fmt::format("column id does not exists in table={}, schema version={},", |
609 | 0 | schema.table_id(), schema.schema_version()); |
610 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>(err_msg); |
611 | 0 | } |
612 | 3.29k | if (!iequal(schema.column_by_uid(cond.column_unique_id).name(), cond.column_name)) { |
613 | 0 | const auto& err_msg = fmt::format( |
614 | 0 | "colum name={} does not belongs to column uid={}, which " |
615 | 0 | "column name={}, " |
616 | 0 | "delete_cond.column_name ={}", |
617 | 0 | cond.column_name, cond.column_unique_id, |
618 | 0 | schema.column_by_uid(cond.column_unique_id).name(), cond.column_name); |
619 | 0 | return Status::Error<ErrorCode::INVALID_ARGUMENT>(err_msg); |
620 | 0 | } |
621 | | |
622 | 3.29k | return Status::OK(); |
623 | 3.29k | } |
624 | | |
625 | | PredicateType DeleteHandler::parse_condition_op(const std::string& op_str, |
626 | 8.83k | const std::list<std::string>& cond_values) { |
627 | 8.83k | if (trim(to_lower(op_str)) == "=") { |
628 | 4.86k | return PredicateType::EQ; |
629 | 4.86k | } else if (trim(to_lower(op_str)) == "!=") { |
630 | 967 | return PredicateType::NE; |
631 | 3.00k | } else if (trim(to_lower(op_str)) == ">>") { |
632 | 524 | return PredicateType::GT; |
633 | 2.47k | } else if (trim(to_lower(op_str)) == "<<") { |
634 | 998 | return PredicateType::LT; |
635 | 1.47k | } else if (trim(to_lower(op_str)) == ">=") { |
636 | 354 | return PredicateType::GE; |
637 | 1.12k | } else if (trim(to_lower(op_str)) == "<=") { |
638 | 612 | return PredicateType::LE; |
639 | 612 | } else if (trim(to_lower(op_str)) == "*=") { |
640 | 0 | return cond_values.size() > 1 ? PredicateType::IN_LIST : PredicateType::EQ; |
641 | 512 | } else if (trim(to_lower(op_str)) == "!*=") { |
642 | 0 | return cond_values.size() > 1 ? PredicateType::NOT_IN_LIST : PredicateType::NE; |
643 | 533 | } else if (trim(to_lower(op_str)) == "is") { |
644 | 533 | return to_lower(cond_values.front()) == "null" ? PredicateType::IS_NULL |
645 | 533 | : PredicateType::IS_NOT_NULL; |
646 | 18.4E | } else { |
647 | 18.4E | throw Exception(Status::Error<ErrorCode::INVALID_ARGUMENT>( |
648 | 18.4E | "invalid condition operator. operator={}", op_str)); |
649 | 18.4E | } |
650 | 0 | return PredicateType::UNKNOWN; |
651 | 8.83k | } |
652 | | |
653 | | DeleteHandler::ConditionParseResult DeleteHandler::parse_condition( |
654 | 8.65k | const DeleteSubPredicatePB& sub_cond) { |
655 | 8.65k | ConditionParseResult res; |
656 | 8.66k | if (!sub_cond.has_column_name() || !sub_cond.has_op() || !sub_cond.has_cond_value()) { |
657 | 0 | throw Exception(Status::Error<ErrorCode::INVALID_ARGUMENT>( |
658 | 0 | "fail to parse condition. condition={} {} {}", sub_cond.column_name(), |
659 | 0 | sub_cond.op(), sub_cond.cond_value())); |
660 | 0 | } |
661 | 8.65k | if (sub_cond.has_column_unique_id()) { |
662 | 8.56k | res.col_unique_id = sub_cond.column_unique_id(); |
663 | 8.56k | } |
664 | 8.65k | res.column_name = sub_cond.column_name(); |
665 | 8.65k | res.value_str.push_back(sub_cond.cond_value()); |
666 | 8.65k | res.condition_op = parse_condition_op(sub_cond.op(), res.value_str); |
667 | 8.65k | return res; |
668 | 8.65k | } |
669 | | |
670 | | // clang-format off |
671 | | // Condition string format, the format is (column_name)(op)(value) |
672 | | // eg: condition_str="c1 = 1597751948193618247 and length(source)<1;\n;\n" |
673 | | // column_name: matches "c1", must include FeNameFormat.java COLUMN_NAME_REGEX |
674 | | // and compactible with any the lagacy |
675 | | // operator: matches "=" |
676 | | // value: matches "1597751948193618247 and length(source)<1;\n;\n" |
677 | | // |
678 | | // For more info, see DeleteHandler::construct_sub_predicates |
679 | | // FIXME(gavin): This is a tricky implementation, it should not be the final resolution, refactor it. |
680 | | const char* const CONDITION_STR_PATTERN = |
681 | | // .----------------- column-name --------------------------. .----------------------- operator ------------------------. .------------ value ----------. |
682 | | R"(([_a-zA-Z@0-9\s/\p{L}][.a-zA-Z0-9_+-/?@#$%^&*"\s,:\p{L}]*)\s*((?:=)|(?:!=)|(?:>>)|(?:<<)|(?:>=)|(?:<=)|(?:\*=)|(?: IS ))\s*('((?:[\s\S]+)?)'|(?:[\s\S]+)?))"; |
683 | | // '----------------- group 1 ------------------------------' '--------------------- group 2 ---------------------------' | '-- group 4--' | |
684 | | // match any of: = != >> << >= <= *= " IS " '----------- group 3 ---------' |
685 | | // match **ANY THING** without(4) |
686 | | // or with(3) single quote |
687 | | // clang-format on |
688 | | RE2 DELETE_HANDLER_REGEX(CONDITION_STR_PATTERN); |
689 | | |
690 | | DeleteHandler::ConditionParseResult DeleteHandler::parse_condition( |
691 | 182 | const std::string& condition_str) { |
692 | 182 | ConditionParseResult res; |
693 | 182 | std::string col_name, op, value, g4; |
694 | | |
695 | 182 | bool matched = RE2::FullMatch(condition_str, DELETE_HANDLER_REGEX, &col_name, &op, &value, |
696 | 182 | &g4); // exact match |
697 | | |
698 | 182 | if (!matched) { |
699 | 0 | throw Exception( |
700 | 0 | Status::InvalidArgument("fail to sub condition. condition={}", condition_str)); |
701 | 0 | } |
702 | | |
703 | 182 | res.column_name = col_name; |
704 | | |
705 | | // match string with single quotes, a = b or a = 'b' |
706 | 182 | if (!g4.empty()) { |
707 | 141 | res.value_str.push_back(g4); |
708 | 141 | } else { |
709 | 41 | res.value_str.push_back(value); |
710 | 41 | } |
711 | 182 | res.condition_op = DeleteHandler::parse_condition_op(op, res.value_str); |
712 | 182 | VLOG_NOTICE << "parsed condition_str: col_name={" << col_name << "} op={" << op << "} val={" |
713 | 48 | << res.value_str.back() << "}"; |
714 | 182 | return res; |
715 | 182 | } |
716 | | |
717 | | template <typename SubPredType> |
718 | | requires(std::is_same_v<SubPredType, DeleteSubPredicatePB> or |
719 | | std::is_same_v<SubPredType, std::string>) |
720 | | Status DeleteHandler::_parse_column_pred(TabletSchemaSPtr complete_schema, |
721 | | TabletSchemaSPtr delete_pred_related_schema, |
722 | | const RepeatedPtrField<SubPredType>& sub_pred_list, |
723 | 8.65k | DeleteConditions* delete_conditions) { |
724 | 8.73k | for (const auto& sub_predicate : sub_pred_list) { |
725 | 8.73k | auto condition = parse_condition(sub_predicate); |
726 | 8.73k | int32_t col_unique_id = -1; |
727 | 8.73k | if constexpr (std::is_same_v<SubPredType, DeleteSubPredicatePB>) { |
728 | 8.65k | if (sub_predicate.has_column_unique_id()) [[likely]] { |
729 | 8.55k | col_unique_id = sub_predicate.column_unique_id(); |
730 | 8.55k | } |
731 | 8.65k | } |
732 | 8.73k | if (col_unique_id < 0) { |
733 | 181 | const auto& column = |
734 | 181 | *DORIS_TRY(delete_pred_related_schema->column(condition.column_name)); |
735 | 181 | col_unique_id = column.unique_id(); |
736 | 181 | } |
737 | 8.73k | condition.col_unique_id = col_unique_id; |
738 | 8.73k | const auto& column = complete_schema->column_by_uid(col_unique_id); |
739 | 8.73k | uint32_t index = complete_schema->field_index(col_unique_id); |
740 | 8.73k | std::shared_ptr<ColumnPredicate> predicate; |
741 | 8.73k | RETURN_IF_ERROR(parse_to_predicate(index, column.name(), column.get_vec_type(), condition, |
742 | 8.73k | _predicate_arena, predicate)); |
743 | 8.72k | if (predicate != nullptr) { |
744 | 8.70k | delete_conditions->column_predicate_vec.push_back(predicate); |
745 | 8.70k | } |
746 | 8.72k | } |
747 | 8.64k | return Status::OK(); |
748 | 8.65k | } _ZN5doris13DeleteHandler18_parse_column_predINS_20DeleteSubPredicatePBEQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEENS_6StatusESt10shared_ptrINS_12TabletSchemaEESD_RKN6google8protobuf16RepeatedPtrFieldIS3_EEPNS_16DeleteConditionsE Line | Count | Source | 723 | 8.33k | DeleteConditions* delete_conditions) { | 724 | 8.65k | for (const auto& sub_predicate : sub_pred_list) { | 725 | 8.65k | auto condition = parse_condition(sub_predicate); | 726 | 8.65k | int32_t col_unique_id = -1; | 727 | 8.65k | if constexpr (std::is_same_v<SubPredType, DeleteSubPredicatePB>) { | 728 | 8.65k | if (sub_predicate.has_column_unique_id()) [[likely]] { | 729 | 8.55k | col_unique_id = sub_predicate.column_unique_id(); | 730 | 8.55k | } | 731 | 8.65k | } | 732 | 8.65k | if (col_unique_id < 0) { | 733 | 100 | const auto& column = | 734 | 100 | *DORIS_TRY(delete_pred_related_schema->column(condition.column_name)); | 735 | 100 | col_unique_id = column.unique_id(); | 736 | 100 | } | 737 | 8.65k | condition.col_unique_id = col_unique_id; | 738 | 8.65k | const auto& column = complete_schema->column_by_uid(col_unique_id); | 739 | 8.65k | uint32_t index = complete_schema->field_index(col_unique_id); | 740 | 8.65k | std::shared_ptr<ColumnPredicate> predicate; | 741 | 8.65k | RETURN_IF_ERROR(parse_to_predicate(index, column.name(), column.get_vec_type(), condition, | 742 | 8.65k | _predicate_arena, predicate)); | 743 | 8.65k | if (predicate != nullptr) { | 744 | 8.63k | delete_conditions->column_predicate_vec.push_back(predicate); | 745 | 8.63k | } | 746 | 8.65k | } | 747 | 8.33k | return Status::OK(); | 748 | 8.33k | } |
_ZN5doris13DeleteHandler18_parse_column_predINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEQoosr3stdE9is_same_vIT_NS_20DeleteSubPredicatePBEEsr3stdE9is_same_vIS8_S7_EEENS_6StatusESt10shared_ptrINS_12TabletSchemaEESD_RKN6google8protobuf16RepeatedPtrFieldIS8_EEPNS_16DeleteConditionsE Line | Count | Source | 723 | 320 | DeleteConditions* delete_conditions) { | 724 | 320 | for (const auto& sub_predicate : sub_pred_list) { | 725 | 81 | auto condition = parse_condition(sub_predicate); | 726 | 81 | int32_t col_unique_id = -1; | 727 | | if constexpr (std::is_same_v<SubPredType, DeleteSubPredicatePB>) { | 728 | | if (sub_predicate.has_column_unique_id()) [[likely]] { | 729 | | col_unique_id = sub_predicate.column_unique_id(); | 730 | | } | 731 | | } | 732 | 81 | if (col_unique_id < 0) { | 733 | 81 | const auto& column = | 734 | 81 | *DORIS_TRY(delete_pred_related_schema->column(condition.column_name)); | 735 | 81 | col_unique_id = column.unique_id(); | 736 | 81 | } | 737 | 81 | condition.col_unique_id = col_unique_id; | 738 | 81 | const auto& column = complete_schema->column_by_uid(col_unique_id); | 739 | 81 | uint32_t index = complete_schema->field_index(col_unique_id); | 740 | 81 | std::shared_ptr<ColumnPredicate> predicate; | 741 | 81 | RETURN_IF_ERROR(parse_to_predicate(index, column.name(), column.get_vec_type(), condition, | 742 | 81 | _predicate_arena, predicate)); | 743 | 74 | if (predicate != nullptr) { | 744 | 74 | delete_conditions->column_predicate_vec.push_back(predicate); | 745 | 74 | } | 746 | 74 | } | 747 | 313 | return Status::OK(); | 748 | 320 | } |
|
749 | | |
750 | | Status DeleteHandler::init(TabletSchemaSPtr tablet_schema, |
751 | 1.29M | const std::vector<RowsetMetaSharedPtr>& delete_preds, int64_t version) { |
752 | 18.4E | DCHECK(!_is_inited) << "reinitialize delete handler."; |
753 | 18.4E | DCHECK(version >= 0) << "invalid parameters. version=" << version; |
754 | | |
755 | 1.29M | for (const auto& delete_pred : delete_preds) { |
756 | | // Skip the delete condition with large version |
757 | 8.65k | if (delete_pred->version().first > version) { |
758 | 0 | continue; |
759 | 0 | } |
760 | | // Need the tablet schema at the delete condition to parse the accurate column |
761 | 8.65k | const auto& delete_pred_related_schema = delete_pred->tablet_schema(); |
762 | 8.65k | const auto& delete_condition = delete_pred->delete_predicate(); |
763 | 8.65k | DeleteConditions temp; |
764 | 8.65k | temp.filter_version = delete_pred->version().first; |
765 | 8.65k | if (!delete_condition.sub_predicates_v2().empty()) { |
766 | 8.33k | RETURN_IF_ERROR(_parse_column_pred(tablet_schema, delete_pred_related_schema, |
767 | 8.33k | delete_condition.sub_predicates_v2(), &temp)); |
768 | 8.33k | } else { |
769 | | // make it compatible with the former versions |
770 | 313 | RETURN_IF_ERROR(_parse_column_pred(tablet_schema, delete_pred_related_schema, |
771 | 313 | delete_condition.sub_predicates(), &temp)); |
772 | 313 | } |
773 | 8.64k | for (const auto& in_predicate : delete_condition.in_predicates()) { |
774 | 364 | ConditionParseResult condition; |
775 | 364 | condition.column_name = in_predicate.column_name(); |
776 | | |
777 | 364 | int32_t col_unique_id = -1; |
778 | 364 | if (in_predicate.has_column_unique_id()) { |
779 | 362 | col_unique_id = in_predicate.column_unique_id(); |
780 | 362 | } else { |
781 | | // if upgrade from version 2.0.x, column_unique_id maybe not set |
782 | 2 | const auto& pre_column = |
783 | 2 | *DORIS_TRY(delete_pred_related_schema->column(condition.column_name)); |
784 | 2 | col_unique_id = pre_column.unique_id(); |
785 | 2 | } |
786 | 364 | if (col_unique_id == -1) { |
787 | 0 | return Status::Error<ErrorCode::DELETE_INVALID_CONDITION>( |
788 | 0 | "cannot get column_unique_id for column {}", condition.column_name); |
789 | 0 | } |
790 | 364 | condition.col_unique_id = col_unique_id; |
791 | | |
792 | 364 | condition.condition_op = |
793 | 364 | in_predicate.is_not_in() ? PredicateType::NOT_IN_LIST : PredicateType::IN_LIST; |
794 | 1.18k | for (const auto& value : in_predicate.values()) { |
795 | 1.18k | condition.value_str.push_back(value); |
796 | 1.18k | } |
797 | 364 | const auto& column = tablet_schema->column_by_uid(col_unique_id); |
798 | 364 | uint32_t index = tablet_schema->field_index(col_unique_id); |
799 | 364 | std::shared_ptr<ColumnPredicate> predicate; |
800 | 364 | RETURN_IF_ERROR(parse_to_in_predicate(index, column.name(), column.get_vec_type(), |
801 | 364 | condition, _predicate_arena, predicate)); |
802 | 364 | temp.column_predicate_vec.push_back(predicate); |
803 | 364 | } |
804 | | |
805 | 8.64k | _del_conds.emplace_back(std::move(temp)); |
806 | 8.64k | } |
807 | | |
808 | 1.29M | _is_inited = true; |
809 | | |
810 | 1.29M | return Status::OK(); |
811 | 1.29M | } |
812 | | |
813 | 1.32M | DeleteHandler::~DeleteHandler() { |
814 | 1.32M | if (!_is_inited) { |
815 | 31.4k | return; |
816 | 31.4k | } |
817 | | |
818 | 1.29M | _del_conds.clear(); |
819 | 1.29M | _is_inited = false; |
820 | 1.29M | } |
821 | | |
822 | | void DeleteHandler::get_delete_conditions_after_version( |
823 | | int64_t version, AndBlockColumnPredicate* and_block_column_predicate_ptr, |
824 | | std::unordered_map<int32_t, std::vector<std::shared_ptr<const ColumnPredicate>>>* |
825 | 3.63M | del_predicates_for_zone_map) const { |
826 | 3.63M | for (const auto& del_cond : _del_conds) { |
827 | 79.7k | if (del_cond.filter_version > version) { |
828 | | // now, only query support delete column predicate operator |
829 | 43.1k | if (!del_cond.column_predicate_vec.empty()) { |
830 | 43.1k | if (del_cond.column_predicate_vec.size() == 1) { |
831 | 41.8k | auto single_column_block_predicate = SingleColumnBlockPredicate::create_unique( |
832 | 41.8k | del_cond.column_predicate_vec[0]); |
833 | 41.8k | and_block_column_predicate_ptr->add_column_predicate( |
834 | 41.8k | std::move(single_column_block_predicate)); |
835 | 41.8k | if (del_predicates_for_zone_map->count( |
836 | 41.8k | del_cond.column_predicate_vec[0]->column_id()) < 1) { |
837 | 20.0k | del_predicates_for_zone_map->insert( |
838 | 20.0k | {del_cond.column_predicate_vec[0]->column_id(), |
839 | 20.0k | std::vector<std::shared_ptr<const ColumnPredicate>> {}}); |
840 | 20.0k | } |
841 | 41.8k | (*del_predicates_for_zone_map)[del_cond.column_predicate_vec[0]->column_id()] |
842 | 41.8k | .push_back(del_cond.column_predicate_vec[0]); |
843 | 41.8k | } else { |
844 | 1.33k | auto or_column_predicate = OrBlockColumnPredicate::create_unique(); |
845 | | |
846 | | // build or_column_predicate |
847 | | // when delete from where a = 1 and b = 2, we can not use del_predicates_for_zone_map to filter zone page, |
848 | | // so here do not put predicate to del_predicates_for_zone_map, |
849 | | // refer #17145 for more details. |
850 | | // // TODO: need refactor design and code to use more version delete and more column delete to filter zone page. |
851 | 1.33k | std::for_each(del_cond.column_predicate_vec.cbegin(), |
852 | 1.33k | del_cond.column_predicate_vec.cend(), |
853 | 1.33k | [&or_column_predicate]( |
854 | 2.88k | const std::shared_ptr<const ColumnPredicate> predicate) { |
855 | 2.88k | or_column_predicate->add_column_predicate( |
856 | 2.88k | SingleColumnBlockPredicate::create_unique(predicate)); |
857 | 2.88k | }); |
858 | 1.33k | and_block_column_predicate_ptr->add_column_predicate( |
859 | 1.33k | std::move(or_column_predicate)); |
860 | 1.33k | } |
861 | 43.1k | } |
862 | 43.1k | } |
863 | 79.7k | } |
864 | 3.63M | } |
865 | | |
866 | | } // namespace doris |