/root/doris/be/src/vec/exprs/vexpr.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <gen_cpp/Exprs_types.h> |
21 | | #include <gen_cpp/Opcodes_types.h> |
22 | | #include <gen_cpp/Types_types.h> |
23 | | #include <glog/logging.h> |
24 | | |
25 | | #include <cstddef> |
26 | | #include <cstdint> |
27 | | #include <memory> |
28 | | #include <ostream> |
29 | | #include <string> |
30 | | #include <utility> |
31 | | #include <vector> |
32 | | |
33 | | #include "common/status.h" |
34 | | #include "olap/rowset/segment_v2/ann_index/ann_search_params.h" |
35 | | #include "olap/rowset/segment_v2/column_reader.h" |
36 | | #include "olap/rowset/segment_v2/index_reader.h" |
37 | | #include "olap/rowset/segment_v2/inverted_index_reader.h" |
38 | | #include "runtime/define_primitive_type.h" |
39 | | #include "runtime/large_int_value.h" |
40 | | #include "runtime/types.h" |
41 | | #include "udf/udf.h" |
42 | | #include "util/date_func.h" |
43 | | #include "vec/aggregate_functions/aggregate_function.h" |
44 | | #include "vec/columns/column.h" |
45 | | #include "vec/core/block.h" |
46 | | #include "vec/core/column_with_type_and_name.h" |
47 | | #include "vec/core/extended_types.h" |
48 | | #include "vec/core/types.h" |
49 | | #include "vec/data_types/data_type.h" |
50 | | #include "vec/data_types/data_type_ipv6.h" |
51 | | #include "vec/exprs/vexpr_context.h" |
52 | | #include "vec/exprs/vexpr_fwd.h" |
53 | | #include "vec/functions/function.h" |
54 | | |
55 | | namespace doris { |
56 | | class BitmapFilterFuncBase; |
57 | | class BloomFilterFuncBase; |
58 | | class HybridSetBase; |
59 | | class ObjectPool; |
60 | | class RowDescriptor; |
61 | | class RuntimeState; |
62 | | |
63 | | namespace segment_v2 { |
64 | | class IndexIterator; |
65 | | class ColumnIterator; |
66 | | struct AnnRangeSearchRuntime; |
67 | | }; // namespace segment_v2 |
68 | | |
69 | | namespace vectorized { |
70 | | #include "common/compile_check_begin.h" |
71 | | #define RETURN_IF_ERROR_OR_PREPARED(stmt) \ |
72 | 258k | if (_prepared) { \ |
73 | 0 | return Status::OK(); \ |
74 | 0 | } \ |
75 | 258k | _prepared = true; \ |
76 | 258k | RETURN_IF_ERROR(stmt); |
77 | | |
78 | | // VExpr should be used as shared pointer because it will be passed between classes |
79 | | // like runtime filter to scan node, or from scannode to scanner. We could not make sure |
80 | | // the relatioinship between threads and classes. |
81 | | class VExpr { |
82 | | public: |
83 | | // resize inserted param column to make sure column size equal to block.rows() and return param column index |
84 | | // keep return type same with block::columns() |
85 | 130 | static uint32_t insert_param(Block* block, ColumnWithTypeAndName&& elem, size_t size) { |
86 | | // usually elem.column always is const column, so we just clone it. |
87 | 130 | elem.column = elem.column->clone_resized(size); |
88 | 130 | block->insert(std::move(elem)); |
89 | | // just inserted. so no need to check underflow. |
90 | 130 | return block->columns() - 1; |
91 | 130 | } |
92 | | |
93 | | static bool is_acting_on_a_slot(const VExpr& expr); |
94 | | |
95 | | VExpr(const TExprNode& node); |
96 | | VExpr(const VExpr& vexpr); |
97 | | VExpr(DataTypePtr type, bool is_slotref); |
98 | | // only used for test |
99 | 935 | VExpr() = default; |
100 | 401k | virtual ~VExpr() = default; |
101 | | |
102 | | virtual const std::string& expr_name() const = 0; |
103 | 0 | virtual std::string expr_label() { return ""; } |
104 | | |
105 | | /// Initializes this expr instance for execution. This does not include initializing |
106 | | /// state in the VExprContext; 'context' should only be used to register a |
107 | | /// FunctionContext via RegisterFunctionContext(). |
108 | | /// |
109 | | /// Subclasses overriding this function should call VExpr::Prepare() to recursively call |
110 | | /// Prepare() on the expr tree |
111 | | /// row_desc used in vslot_ref and some subclass to specify column |
112 | | virtual Status prepare(RuntimeState* state, const RowDescriptor& row_desc, |
113 | | VExprContext* context); |
114 | | |
115 | | /// Initializes 'context' for execution. If scope if FRAGMENT_LOCAL, both fragment- and |
116 | | /// thread-local state should be initialized. Otherwise, if scope is THREAD_LOCAL, only |
117 | | /// thread-local state should be initialized. |
118 | | // |
119 | | /// Subclasses overriding this function should call VExpr::Open() to recursively call |
120 | | /// Open() on the expr tree |
121 | | virtual Status open(RuntimeState* state, VExprContext* context, |
122 | | FunctionContext::FunctionStateScope scope); |
123 | | |
124 | | // before execute, check if expr has been parepared+opened. |
125 | 0 | [[maybe_unused]] Status ready_status() const { |
126 | 0 | if (_prepare_finished && _open_finished) { |
127 | 0 | return Status::OK(); |
128 | 0 | } |
129 | 0 | return Status::InternalError(expr_name() + " is not ready when execute"); |
130 | 0 | } |
131 | | |
132 | | virtual Status execute(VExprContext* context, Block* block, int* result_column_id) = 0; |
133 | | // `is_blockable` means this expr will be blocked in `execute` (e.g. AI Function, Remote Function) |
134 | 0 | [[nodiscard]] virtual bool is_blockable() const { return false; } |
135 | | |
136 | | // execute current expr with inverted index to filter block. Given a roaring bitmap of match rows |
137 | 0 | virtual Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) { |
138 | 0 | return Status::OK(); |
139 | 0 | } |
140 | | |
141 | | Status _evaluate_inverted_index(VExprContext* context, const FunctionBasePtr& function, |
142 | | uint32_t segment_num_rows); |
143 | | |
144 | | virtual size_t estimate_memory(const size_t rows); |
145 | | |
146 | | // Only the 4th parameter is used in the runtime filter. In and MinMax need overwrite the |
147 | | // interface |
148 | | virtual Status execute_runtime_filter(VExprContext* context, Block* block, |
149 | 0 | int* result_column_id, ColumnNumbers& args) { |
150 | 0 | return execute(context, block, result_column_id); |
151 | 0 | }; |
152 | | |
153 | | /// Subclasses overriding this function should call VExpr::Close(). |
154 | | // |
155 | | /// If scope if FRAGMENT_LOCAL, both fragment- and thread-local state should be torn |
156 | | /// down. Otherwise, if scope is THREAD_LOCAL, only thread-local state should be torn |
157 | | /// down. |
158 | | virtual void close(VExprContext* context, FunctionContext::FunctionStateScope scope); |
159 | | |
160 | 891k | DataTypePtr& data_type() { return _data_type; } |
161 | | |
162 | 127 | bool is_slot_ref() const { return _node_type == TExprNodeType::SLOT_REF; } |
163 | | |
164 | 0 | bool is_column_ref() const { return _node_type == TExprNodeType::COLUMN_REF; } |
165 | | |
166 | 89 | virtual bool is_literal() const { return false; } |
167 | | |
168 | 5.46k | MOCK_FUNCTION TExprNodeType::type node_type() const { return _node_type; } |
169 | | |
170 | 169 | TExprOpcode::type op() const { return _opcode; } |
171 | | |
172 | 486 | void add_child(const VExprSPtr& expr) { _children.push_back(expr); } |
173 | 29 | VExprSPtr get_child(uint16_t i) const { return _children[i]; } |
174 | | // Expr's children number is restricted by org.apache.doris.common.Config#expr_children_limit, 10000 default. and strongly not recommend to change. |
175 | | // There's little to worry about it. uint16 is enough. |
176 | 183 | uint16_t get_num_children() const { return static_cast<uint16_t>(_children.size()); } |
177 | | |
178 | 222 | virtual bool is_rf_wrapper() const { |
179 | 222 | return std::ranges::any_of(_children.begin(), _children.end(), |
180 | 222 | [](VExprSPtr child) { return child->is_rf_wrapper(); }); |
181 | 222 | } |
182 | | |
183 | 0 | virtual void do_judge_selectivity(uint64_t filter_rows, uint64_t input_rows) { |
184 | 0 | for (auto child : _children) { |
185 | 0 | child->do_judge_selectivity(filter_rows, input_rows); |
186 | 0 | } |
187 | 0 | } |
188 | | |
189 | | static Status create_expr_tree(const TExpr& texpr, VExprContextSPtr& ctx); |
190 | | |
191 | | static Status create_expr_trees(const std::vector<TExpr>& texprs, VExprContextSPtrs& ctxs); |
192 | | |
193 | | static Status prepare(const VExprContextSPtrs& ctxs, RuntimeState* state, |
194 | | const RowDescriptor& row_desc); |
195 | | |
196 | | static Status open(const VExprContextSPtrs& ctxs, RuntimeState* state); |
197 | | |
198 | | static Status clone_if_not_exists(const VExprContextSPtrs& ctxs, RuntimeState* state, |
199 | | VExprContextSPtrs& new_ctxs); |
200 | | |
201 | 47 | bool is_nullable() const { return _data_type->is_nullable(); } |
202 | | |
203 | 0 | PrimitiveType result_type() const { return _data_type->get_primitive_type(); } |
204 | | |
205 | | static Status create_expr(const TExprNode& expr_node, VExprSPtr& expr); |
206 | | |
207 | | static Status create_tree_from_thrift(const std::vector<TExprNode>& nodes, int* node_idx, |
208 | | VExprSPtr& root_expr, VExprContextSPtr& ctx); |
209 | | |
210 | | static Status check_expr_output_type(const VExprContextSPtrs& ctxs, |
211 | | const RowDescriptor& output_row_desc); |
212 | 5.24k | virtual const VExprSPtrs& children() const { return _children; } |
213 | 0 | void set_children(const VExprSPtrs& children) { _children = children; } |
214 | 0 | void set_children(VExprSPtrs&& children) { _children = std::move(children); } |
215 | | virtual std::string debug_string() const; |
216 | | static std::string debug_string(const VExprSPtrs& exprs); |
217 | | static std::string debug_string(const VExprContextSPtrs& ctxs); |
218 | | |
219 | 0 | void set_getting_const_col(bool val = true) { _getting_const_col = val; } |
220 | | |
221 | 83 | bool is_and_expr() const { return _fn.name.function_name == "and"; } |
222 | | |
223 | 0 | virtual bool is_compound_predicate() const { return false; } |
224 | | |
225 | 299 | const TFunction& fn() const { return _fn; } |
226 | | |
227 | | /// Returns true if expr doesn't contain slotrefs, i.e., can be evaluated |
228 | | /// with get_value(NULL). The default implementation returns true if all of |
229 | | /// the children are constant. |
230 | | virtual bool is_constant() const; |
231 | | |
232 | | /// If this expr is constant, evaluates the expr with no input row argument and returns |
233 | | /// the output. Returns nullptr if the argument is not constant. The returned ColumnPtr is |
234 | | /// owned by this expr. This should only be called after Open() has been called on this |
235 | | /// expr. |
236 | | MOCK_FUNCTION Status get_const_col(VExprContext* context, |
237 | | std::shared_ptr<ColumnPtrWrapper>* column_wrapper); |
238 | | |
239 | 22 | int fn_context_index() const { return _fn_context_index; } |
240 | | |
241 | 537 | static VExprSPtr expr_without_cast(const VExprSPtr& expr) { |
242 | 537 | if (expr->node_type() == TExprNodeType::CAST_EXPR) { |
243 | 5 | return expr_without_cast(expr->_children[0]); |
244 | 5 | } |
245 | 532 | return expr; |
246 | 537 | } |
247 | | |
248 | | // If this expr is a RuntimeFilterWrapper, this method will return an underlying rf expression |
249 | 83 | virtual VExprSPtr get_impl() const { return {}; } |
250 | | |
251 | | // If this expr is a BloomPredicate, this method will return a BloomFilterFunc |
252 | 0 | virtual std::shared_ptr<BloomFilterFuncBase> get_bloom_filter_func() const { |
253 | 0 | throw Exception(Status::FatalError( |
254 | 0 | "Method 'get_bloom_filter_func()' is not supported in expression: {}", |
255 | 0 | this->debug_string())); |
256 | 0 | } |
257 | | |
258 | 13 | virtual std::shared_ptr<HybridSetBase> get_set_func() const { return nullptr; } |
259 | | |
260 | | // If this expr is a BitmapPredicate, this method will return a BitmapFilterFunc |
261 | 0 | virtual std::shared_ptr<BitmapFilterFuncBase> get_bitmap_filter_func() const { |
262 | 0 | throw Exception(Status::FatalError( |
263 | 0 | "Method 'get_bitmap_filter_func()' is not supported in expression: {}", |
264 | 0 | this->debug_string())); |
265 | 0 | } |
266 | | |
267 | | // fast_execute can direct copy expr filter result which build by apply index in segment_iterator |
268 | | bool fast_execute(doris::vectorized::VExprContext* context, doris::vectorized::Block* block, |
269 | | int* result_column_id); |
270 | | |
271 | 0 | virtual bool can_push_down_to_index() const { return false; } |
272 | | virtual bool equals(const VExpr& other); |
273 | 0 | void set_index_unique_id(uint32_t index_unique_id) { _index_unique_id = index_unique_id; } |
274 | 0 | uint32_t index_unique_id() const { return _index_unique_id; } |
275 | | |
276 | 20 | virtual void collect_slot_column_ids(std::set<int>& column_ids) const { |
277 | 24 | for (auto child : _children) { |
278 | 24 | child->collect_slot_column_ids(column_ids); |
279 | 24 | } |
280 | 20 | } |
281 | | |
282 | | #ifdef BE_TEST |
283 | 0 | void set_node_type(TExprNodeType::type node_type) { _node_type = node_type; } |
284 | | #endif |
285 | | virtual Status evaluate_ann_range_search( |
286 | | const segment_v2::AnnRangeSearchRuntime& runtime, |
287 | | const std::vector<std::unique_ptr<segment_v2::IndexIterator>>& cid_to_index_iterators, |
288 | | const std::vector<ColumnId>& idx_to_cid, |
289 | | const std::vector<std::unique_ptr<segment_v2::ColumnIterator>>& column_iterators, |
290 | | roaring::Roaring& row_bitmap, segment_v2::AnnIndexStats& ann_index_stats); |
291 | | |
292 | | // Prepare the runtime for ANN range search. |
293 | | // AnnRangeSearchRuntime is used to store the runtime information of ann range search. |
294 | | // suitable_for_ann_index is used to indicate whether the current expr can be used for ANN range search. |
295 | | // If suitable_for_ann_index is false, the we will do exhausted search. |
296 | | virtual void prepare_ann_range_search(const doris::VectorSearchUserParams& params, |
297 | | segment_v2::AnnRangeSearchRuntime& range_search_runtime, |
298 | | bool& suitable_for_ann_index); |
299 | | |
300 | | bool has_been_executed(); |
301 | | |
302 | | protected: |
303 | | /// Simple debug string that provides no expr subclass-specific information |
304 | 0 | std::string debug_string(const std::string& expr_name) const { |
305 | 0 | std::stringstream out; |
306 | 0 | out << expr_name << "(" << VExpr::debug_string() << ")"; |
307 | 0 | return out.str(); |
308 | 0 | } |
309 | | |
310 | | // used in expr name |
311 | 86 | std::string get_child_names() { |
312 | 86 | std::string res; |
313 | 131 | for (auto child : _children) { |
314 | 131 | if (!res.empty()) { |
315 | 49 | res += ", "; |
316 | 49 | } |
317 | 131 | res += child->expr_name(); |
318 | 131 | } |
319 | 86 | return res; |
320 | 86 | } |
321 | | |
322 | | // only for errmsg now |
323 | 1 | std::string get_child_type_names() { |
324 | 1 | std::string res; |
325 | 2 | for (auto child : _children) { |
326 | 2 | if (!res.empty()) { |
327 | 1 | res += ", "; |
328 | 1 | } |
329 | 2 | res += child->expr_name() + ": " + child->data_type()->get_name(); |
330 | 2 | } |
331 | 1 | return res; |
332 | 1 | } |
333 | | |
334 | 8 | bool is_const_and_have_executed() { return (is_constant() && (_constant_col != nullptr)); } |
335 | | |
336 | | Status get_result_from_const(vectorized::Block* block, const std::string& expr_name, |
337 | | int* result_column_id); |
338 | | |
339 | | Status check_constant(const Block& block, ColumnNumbers arguments) const; |
340 | | |
341 | | /// Helper function that calls ctx->register(), sets fn_context_index_, and returns the |
342 | | /// registered FunctionContext |
343 | | void register_function_context(RuntimeState* state, VExprContext* context); |
344 | | |
345 | | /// Helper function to initialize function context, called in `open` phase of VExpr: |
346 | | /// 1. Set constant columns result of function arguments. |
347 | | /// 2. Call function's prepare() to initialize function state, fragment-local or |
348 | | /// thread-local according the input `FunctionStateScope` argument. |
349 | | Status init_function_context(RuntimeState* state, VExprContext* context, |
350 | | FunctionContext::FunctionStateScope scope, |
351 | | const FunctionBasePtr& function) const; |
352 | | |
353 | | /// Helper function to close function context, fragment-local or thread-local according |
354 | | /// the input `FunctionStateScope` argument. Called in `close` phase of VExpr. |
355 | | void close_function_context(VExprContext* context, FunctionContext::FunctionStateScope scope, |
356 | | const FunctionBasePtr& function) const; |
357 | | |
358 | | TExprNodeType::type _node_type; |
359 | | // Used to check what opcode |
360 | | TExprOpcode::type _opcode; |
361 | | DataTypePtr _data_type; |
362 | | VExprSPtrs _children; // in few hundreds |
363 | | TFunction _fn; |
364 | | |
365 | | /// Index to pass to ExprContext::fn_context() to retrieve this expr's FunctionContext. |
366 | | /// Set in RegisterFunctionContext(). -1 if this expr does not need a FunctionContext and |
367 | | /// doesn't call RegisterFunctionContext(). |
368 | | int _fn_context_index = -1; |
369 | | |
370 | | // If this expr is constant, this will store and cache the value generated by |
371 | | // get_const_col() |
372 | | std::shared_ptr<ColumnPtrWrapper> _constant_col; |
373 | | bool _prepared = false; // for base class VExpr |
374 | | bool _getting_const_col = |
375 | | false; // if true, current execute() is in prepare() (that is, can't check _prepared) |
376 | | // for concrete classes |
377 | | bool _prepare_finished = false; |
378 | | bool _open_finished = false; |
379 | | |
380 | | // ensuring uniqueness during index traversal |
381 | | uint32_t _index_unique_id = 0; |
382 | | bool _enable_inverted_index_query = true; |
383 | | |
384 | | bool _has_been_executed = false; |
385 | | }; |
386 | | |
387 | | } // namespace vectorized |
388 | | |
389 | | // NOLINTBEGIN(readability-function-size) |
390 | | template <PrimitiveType T> |
391 | | Status create_texpr_literal_node(const void* data, TExprNode* node, int precision = 0, |
392 | 38 | int scale = 0) { |
393 | 38 | if constexpr (T == TYPE_BOOLEAN) { |
394 | 1 | const auto* origin_value = reinterpret_cast<const bool*>(data); |
395 | 1 | TBoolLiteral boolLiteral; |
396 | 1 | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); |
397 | 1 | boolLiteral.__set_value(*origin_value); |
398 | 1 | (*node).__set_bool_literal(boolLiteral); |
399 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); |
400 | 1 | } else if constexpr (T == TYPE_TINYINT) { |
401 | 0 | const auto* origin_value = reinterpret_cast<const int8_t*>(data); |
402 | 0 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
403 | 0 | TIntLiteral intLiteral; |
404 | 0 | intLiteral.__set_value(*origin_value); |
405 | 0 | (*node).__set_int_literal(intLiteral); |
406 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); |
407 | 1 | } else if constexpr (T == TYPE_SMALLINT) { |
408 | 1 | const auto* origin_value = reinterpret_cast<const int16_t*>(data); |
409 | 1 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
410 | 1 | TIntLiteral intLiteral; |
411 | 1 | intLiteral.__set_value(*origin_value); |
412 | 1 | (*node).__set_int_literal(intLiteral); |
413 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); |
414 | 6 | } else if constexpr (T == TYPE_INT) { |
415 | 6 | const auto* origin_value = reinterpret_cast<const int32_t*>(data); |
416 | 6 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
417 | 6 | TIntLiteral intLiteral; |
418 | 6 | intLiteral.__set_value(*origin_value); |
419 | 6 | (*node).__set_int_literal(intLiteral); |
420 | 6 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); |
421 | 12 | } else if constexpr (T == TYPE_BIGINT) { |
422 | 12 | const auto* origin_value = reinterpret_cast<const int64_t*>(data); |
423 | 12 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
424 | 12 | TIntLiteral intLiteral; |
425 | 12 | intLiteral.__set_value(*origin_value); |
426 | 12 | (*node).__set_int_literal(intLiteral); |
427 | 12 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); |
428 | 12 | } else if constexpr (T == TYPE_LARGEINT) { |
429 | 1 | const auto* origin_value = reinterpret_cast<const int128_t*>(data); |
430 | 1 | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); |
431 | 1 | TLargeIntLiteral large_int_literal; |
432 | 1 | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); |
433 | 1 | (*node).__set_large_int_literal(large_int_literal); |
434 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); |
435 | 2 | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { |
436 | 2 | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); |
437 | 2 | TDateLiteral date_literal; |
438 | 2 | char convert_buffer[30]; |
439 | 2 | origin_value->to_string(convert_buffer); |
440 | 2 | date_literal.__set_value(convert_buffer); |
441 | 2 | (*node).__set_date_literal(date_literal); |
442 | 2 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); |
443 | 2 | if (origin_value->type() == TimeType::TIME_DATE) { |
444 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); |
445 | 1 | } else if (origin_value->type() == TimeType::TIME_DATETIME) { |
446 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); |
447 | 1 | } |
448 | 2 | } else if constexpr (T == TYPE_DATEV2) { |
449 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); |
450 | 1 | TDateLiteral date_literal; |
451 | 1 | char convert_buffer[30]; |
452 | 1 | origin_value->to_string(convert_buffer); |
453 | 1 | date_literal.__set_value(convert_buffer); |
454 | 1 | (*node).__set_date_literal(date_literal); |
455 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); |
456 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); |
457 | 1 | } else if constexpr (T == TYPE_DATETIMEV2) { |
458 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); |
459 | 1 | TDateLiteral date_literal; |
460 | 1 | char convert_buffer[30]; |
461 | 1 | origin_value->to_string(convert_buffer, scale); |
462 | 1 | date_literal.__set_value(convert_buffer); |
463 | 1 | (*node).__set_date_literal(date_literal); |
464 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); |
465 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); |
466 | 1 | } else if constexpr (T == TYPE_DECIMALV2) { |
467 | 1 | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); |
468 | 1 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
469 | 1 | TDecimalLiteral decimal_literal; |
470 | 1 | decimal_literal.__set_value(origin_value->to_string()); |
471 | 1 | (*node).__set_decimal_literal(decimal_literal); |
472 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); |
473 | 2 | } else if constexpr (T == TYPE_DECIMAL32) { |
474 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); |
475 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
476 | 2 | TDecimalLiteral decimal_literal; |
477 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
478 | 2 | (*node).__set_decimal_literal(decimal_literal); |
479 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); |
480 | 2 | } else if constexpr (T == TYPE_DECIMAL64) { |
481 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); |
482 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
483 | 2 | TDecimalLiteral decimal_literal; |
484 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
485 | 2 | (*node).__set_decimal_literal(decimal_literal); |
486 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); |
487 | 2 | } else if constexpr (T == TYPE_DECIMAL128I) { |
488 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); |
489 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
490 | 2 | TDecimalLiteral decimal_literal; |
491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF |
492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the |
493 | | // final min value of the MinMax RF if the fragment instance has no data. |
494 | | // Need to truncate the value to the right precision and scale here, to avoid |
495 | | // error when casting string back to decimal later. |
496 | | // TODO: this is a temporary solution, the best solution is to produce the |
497 | | // right min max value at the producer side. |
498 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
499 | 2 | (*node).__set_decimal_literal(decimal_literal); |
500 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); |
501 | 2 | } else if constexpr (T == TYPE_DECIMAL256) { |
502 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); |
503 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
504 | 2 | TDecimalLiteral decimal_literal; |
505 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
506 | 2 | (*node).__set_decimal_literal(decimal_literal); |
507 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); |
508 | 2 | } else if constexpr (T == TYPE_FLOAT) { |
509 | 1 | const auto* origin_value = reinterpret_cast<const float*>(data); |
510 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); |
511 | 1 | TFloatLiteral float_literal; |
512 | 1 | float_literal.__set_value(*origin_value); |
513 | 1 | (*node).__set_float_literal(float_literal); |
514 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); |
515 | 1 | } else if constexpr (T == TYPE_DOUBLE) { |
516 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); |
517 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); |
518 | 1 | TFloatLiteral float_literal; |
519 | 1 | float_literal.__set_value(*origin_value); |
520 | 1 | (*node).__set_float_literal(float_literal); |
521 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); |
522 | 1 | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { |
523 | 1 | const auto* origin_value = reinterpret_cast<const std::string*>(data); |
524 | 1 | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); |
525 | 1 | TStringLiteral string_literal; |
526 | 1 | string_literal.__set_value(*origin_value); |
527 | 1 | (*node).__set_string_literal(string_literal); |
528 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); |
529 | 1 | } else if constexpr (T == TYPE_IPV4) { |
530 | 0 | const auto* origin_value = reinterpret_cast<const IPv4*>(data); |
531 | 0 | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); |
532 | 0 | TIPv4Literal literal; |
533 | 0 | literal.__set_value(*origin_value); |
534 | 0 | (*node).__set_ipv4_literal(literal); |
535 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); |
536 | 0 | } else if constexpr (T == TYPE_IPV6) { |
537 | 0 | const auto* origin_value = reinterpret_cast<const IPv6*>(data); |
538 | 0 | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); |
539 | 0 | TIPv6Literal literal; |
540 | 0 | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); |
541 | 0 | (*node).__set_ipv6_literal(literal); |
542 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); |
543 | 1 | } else if constexpr (T == TYPE_TIMEV2) { |
544 | | // the code use for runtime filter but we dont support timev2 as predicate now |
545 | | // so this part not used |
546 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); |
547 | 1 | TTimeV2Literal timev2_literal; |
548 | 1 | timev2_literal.__set_value(*origin_value); |
549 | 1 | (*node).__set_timev2_literal(timev2_literal); |
550 | 1 | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); |
551 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); |
552 | | } else { |
553 | | return Status::InvalidArgument("Invalid argument type!"); |
554 | | } |
555 | 38 | return Status::OK(); |
556 | 38 | } _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE2EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | 1 | if constexpr (T == TYPE_BOOLEAN) { | 394 | 1 | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | 1 | TBoolLiteral boolLiteral; | 396 | 1 | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | 1 | boolLiteral.__set_value(*origin_value); | 398 | 1 | (*node).__set_bool_literal(boolLiteral); | 399 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE3EEENS_6StatusEPKvPNS_9TExprNodeEii _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE4EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | 1 | } else if constexpr (T == TYPE_SMALLINT) { | 408 | 1 | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | 1 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | 1 | TIntLiteral intLiteral; | 411 | 1 | intLiteral.__set_value(*origin_value); | 412 | 1 | (*node).__set_int_literal(intLiteral); | 413 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE5EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 6 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | 6 | } else if constexpr (T == TYPE_INT) { | 415 | 6 | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | 6 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | 6 | TIntLiteral intLiteral; | 418 | 6 | intLiteral.__set_value(*origin_value); | 419 | 6 | (*node).__set_int_literal(intLiteral); | 420 | 6 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 6 | return Status::OK(); | 556 | 6 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE6EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 12 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | 12 | } else if constexpr (T == TYPE_BIGINT) { | 422 | 12 | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | 12 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | 12 | TIntLiteral intLiteral; | 425 | 12 | intLiteral.__set_value(*origin_value); | 426 | 12 | (*node).__set_int_literal(intLiteral); | 427 | 12 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 12 | return Status::OK(); | 556 | 12 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE7EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | 1 | } else if constexpr (T == TYPE_LARGEINT) { | 429 | 1 | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | 1 | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | 1 | TLargeIntLiteral large_int_literal; | 432 | 1 | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | 1 | (*node).__set_large_int_literal(large_int_literal); | 434 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE8EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | 1 | } else if constexpr (T == TYPE_FLOAT) { | 509 | 1 | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | 1 | TFloatLiteral float_literal; | 512 | 1 | float_literal.__set_value(*origin_value); | 513 | 1 | (*node).__set_float_literal(float_literal); | 514 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE9EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | 1 | } else if constexpr (T == TYPE_DOUBLE) { | 516 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | 1 | TFloatLiteral float_literal; | 519 | 1 | float_literal.__set_value(*origin_value); | 520 | 1 | (*node).__set_float_literal(float_literal); | 521 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE25EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | 1 | } else if constexpr (T == TYPE_DATEV2) { | 449 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | 1 | TDateLiteral date_literal; | 451 | 1 | char convert_buffer[30]; | 452 | 1 | origin_value->to_string(convert_buffer); | 453 | 1 | date_literal.__set_value(convert_buffer); | 454 | 1 | (*node).__set_date_literal(date_literal); | 455 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE26EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | 1 | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | 1 | TDateLiteral date_literal; | 460 | 1 | char convert_buffer[30]; | 461 | 1 | origin_value->to_string(convert_buffer, scale); | 462 | 1 | date_literal.__set_value(convert_buffer); | 463 | 1 | (*node).__set_date_literal(date_literal); | 464 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE11EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | 1 | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | 1 | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | 1 | TDateLiteral date_literal; | 438 | 1 | char convert_buffer[30]; | 439 | 1 | origin_value->to_string(convert_buffer); | 440 | 1 | date_literal.__set_value(convert_buffer); | 441 | 1 | (*node).__set_date_literal(date_literal); | 442 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | 1 | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | 1 | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | 0 | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE12EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | 1 | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | 1 | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | 1 | TDateLiteral date_literal; | 438 | 1 | char convert_buffer[30]; | 439 | 1 | origin_value->to_string(convert_buffer); | 440 | 1 | date_literal.__set_value(convert_buffer); | 441 | 1 | (*node).__set_date_literal(date_literal); | 442 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | 1 | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | 1 | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | 1 | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE20EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | 1 | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | 1 | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | 1 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | 1 | TDecimalLiteral decimal_literal; | 470 | 1 | decimal_literal.__set_value(origin_value->to_string()); | 471 | 1 | (*node).__set_decimal_literal(decimal_literal); | 472 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE28EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 2 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | 2 | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | 2 | TDecimalLiteral decimal_literal; | 477 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | 2 | (*node).__set_decimal_literal(decimal_literal); | 479 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 2 | return Status::OK(); | 556 | 2 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE29EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 2 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | 2 | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | 2 | TDecimalLiteral decimal_literal; | 484 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | 2 | (*node).__set_decimal_literal(decimal_literal); | 486 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 2 | return Status::OK(); | 556 | 2 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE30EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 2 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | 2 | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | 2 | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | 2 | (*node).__set_decimal_literal(decimal_literal); | 500 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 2 | return Status::OK(); | 556 | 2 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE35EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 2 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | 2 | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | 2 | TDecimalLiteral decimal_literal; | 505 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | 2 | (*node).__set_decimal_literal(decimal_literal); | 507 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 2 | return Status::OK(); | 556 | 2 | } |
Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE15EEENS_6StatusEPKvPNS_9TExprNodeEii Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE10EEENS_6StatusEPKvPNS_9TExprNodeEii _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE23EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | 1 | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | 1 | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | 1 | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | 1 | TStringLiteral string_literal; | 526 | 1 | string_literal.__set_value(*origin_value); | 527 | 1 | (*node).__set_string_literal(string_literal); | 528 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | | TTimeV2Literal timev2_literal; | 548 | | timev2_literal.__set_value(*origin_value); | 549 | | (*node).__set_timev2_literal(timev2_literal); | 550 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE36EEENS_6StatusEPKvPNS_9TExprNodeEii Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE37EEENS_6StatusEPKvPNS_9TExprNodeEii _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE27EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 392 | 1 | int scale = 0) { | 393 | | if constexpr (T == TYPE_BOOLEAN) { | 394 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 395 | | TBoolLiteral boolLiteral; | 396 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 397 | | boolLiteral.__set_value(*origin_value); | 398 | | (*node).__set_bool_literal(boolLiteral); | 399 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 400 | | } else if constexpr (T == TYPE_TINYINT) { | 401 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 402 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 403 | | TIntLiteral intLiteral; | 404 | | intLiteral.__set_value(*origin_value); | 405 | | (*node).__set_int_literal(intLiteral); | 406 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 407 | | } else if constexpr (T == TYPE_SMALLINT) { | 408 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 409 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 410 | | TIntLiteral intLiteral; | 411 | | intLiteral.__set_value(*origin_value); | 412 | | (*node).__set_int_literal(intLiteral); | 413 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 414 | | } else if constexpr (T == TYPE_INT) { | 415 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 416 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 417 | | TIntLiteral intLiteral; | 418 | | intLiteral.__set_value(*origin_value); | 419 | | (*node).__set_int_literal(intLiteral); | 420 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 421 | | } else if constexpr (T == TYPE_BIGINT) { | 422 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 423 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 424 | | TIntLiteral intLiteral; | 425 | | intLiteral.__set_value(*origin_value); | 426 | | (*node).__set_int_literal(intLiteral); | 427 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 428 | | } else if constexpr (T == TYPE_LARGEINT) { | 429 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 430 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 431 | | TLargeIntLiteral large_int_literal; | 432 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 433 | | (*node).__set_large_int_literal(large_int_literal); | 434 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 435 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 436 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 437 | | TDateLiteral date_literal; | 438 | | char convert_buffer[30]; | 439 | | origin_value->to_string(convert_buffer); | 440 | | date_literal.__set_value(convert_buffer); | 441 | | (*node).__set_date_literal(date_literal); | 442 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 443 | | if (origin_value->type() == TimeType::TIME_DATE) { | 444 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 445 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 446 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 447 | | } | 448 | | } else if constexpr (T == TYPE_DATEV2) { | 449 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data); | 450 | | TDateLiteral date_literal; | 451 | | char convert_buffer[30]; | 452 | | origin_value->to_string(convert_buffer); | 453 | | date_literal.__set_value(convert_buffer); | 454 | | (*node).__set_date_literal(date_literal); | 455 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 456 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 457 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 458 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 459 | | TDateLiteral date_literal; | 460 | | char convert_buffer[30]; | 461 | | origin_value->to_string(convert_buffer, scale); | 462 | | date_literal.__set_value(convert_buffer); | 463 | | (*node).__set_date_literal(date_literal); | 464 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 465 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 466 | | } else if constexpr (T == TYPE_DECIMALV2) { | 467 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 468 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 469 | | TDecimalLiteral decimal_literal; | 470 | | decimal_literal.__set_value(origin_value->to_string()); | 471 | | (*node).__set_decimal_literal(decimal_literal); | 472 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 473 | | } else if constexpr (T == TYPE_DECIMAL32) { | 474 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 475 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 476 | | TDecimalLiteral decimal_literal; | 477 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 478 | | (*node).__set_decimal_literal(decimal_literal); | 479 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 480 | | } else if constexpr (T == TYPE_DECIMAL64) { | 481 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 482 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 483 | | TDecimalLiteral decimal_literal; | 484 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 485 | | (*node).__set_decimal_literal(decimal_literal); | 486 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 487 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 488 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 489 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 490 | | TDecimalLiteral decimal_literal; | 491 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 492 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 493 | | // final min value of the MinMax RF if the fragment instance has no data. | 494 | | // Need to truncate the value to the right precision and scale here, to avoid | 495 | | // error when casting string back to decimal later. | 496 | | // TODO: this is a temporary solution, the best solution is to produce the | 497 | | // right min max value at the producer side. | 498 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 499 | | (*node).__set_decimal_literal(decimal_literal); | 500 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 501 | | } else if constexpr (T == TYPE_DECIMAL256) { | 502 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 503 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 504 | | TDecimalLiteral decimal_literal; | 505 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 506 | | (*node).__set_decimal_literal(decimal_literal); | 507 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 508 | | } else if constexpr (T == TYPE_FLOAT) { | 509 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 510 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 511 | | TFloatLiteral float_literal; | 512 | | float_literal.__set_value(*origin_value); | 513 | | (*node).__set_float_literal(float_literal); | 514 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 515 | | } else if constexpr (T == TYPE_DOUBLE) { | 516 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 517 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 518 | | TFloatLiteral float_literal; | 519 | | float_literal.__set_value(*origin_value); | 520 | | (*node).__set_float_literal(float_literal); | 521 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 522 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 523 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 524 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 525 | | TStringLiteral string_literal; | 526 | | string_literal.__set_value(*origin_value); | 527 | | (*node).__set_string_literal(string_literal); | 528 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 529 | | } else if constexpr (T == TYPE_IPV4) { | 530 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 531 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 532 | | TIPv4Literal literal; | 533 | | literal.__set_value(*origin_value); | 534 | | (*node).__set_ipv4_literal(literal); | 535 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 536 | | } else if constexpr (T == TYPE_IPV6) { | 537 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 538 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 539 | | TIPv6Literal literal; | 540 | | literal.__set_value(vectorized::DataTypeIPv6::to_string(*origin_value)); | 541 | | (*node).__set_ipv6_literal(literal); | 542 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 543 | 1 | } else if constexpr (T == TYPE_TIMEV2) { | 544 | | // the code use for runtime filter but we dont support timev2 as predicate now | 545 | | // so this part not used | 546 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); | 547 | 1 | TTimeV2Literal timev2_literal; | 548 | 1 | timev2_literal.__set_value(*origin_value); | 549 | 1 | (*node).__set_timev2_literal(timev2_literal); | 550 | 1 | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 551 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 552 | | } else { | 553 | | return Status::InvalidArgument("Invalid argument type!"); | 554 | | } | 555 | 1 | return Status::OK(); | 556 | 1 | } |
|
557 | | // NOLINTEND(readability-function-size) |
558 | | |
559 | | TExprNode create_texpr_node_from(const void* data, const PrimitiveType& type, int precision = 0, |
560 | | int scale = 0); |
561 | | |
562 | | TExprNode create_texpr_node_from(const vectorized::Field& field, const PrimitiveType& type, |
563 | | int precision, int scale); |
564 | | |
565 | | #include "common/compile_check_end.h" |
566 | | } // namespace doris |