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