/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) = 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 | 0 | const DataTypePtr& data_type() const { return _data_type; } |
167 | | |
168 | 131 | bool is_slot_ref() const { return _node_type == TExprNodeType::SLOT_REF; } |
169 | | |
170 | 0 | bool is_column_ref() const { return _node_type == TExprNodeType::COLUMN_REF; } |
171 | | |
172 | 95 | virtual bool is_literal() const { return false; } |
173 | | |
174 | 5.46k | MOCK_FUNCTION TExprNodeType::type node_type() const { return _node_type; } |
175 | | |
176 | 172 | TExprOpcode::type op() const { return _opcode; } |
177 | | |
178 | 574 | void add_child(const VExprSPtr& expr) { _children.push_back(expr); } |
179 | 35 | VExprSPtr get_child(uint16_t i) const { return _children[i]; } |
180 | | // Expr's children number is restricted by org.apache.doris.common.Config#expr_children_limit, 10000 default. and strongly not recommend to change. |
181 | | // There's little to worry about it. uint16 is enough. |
182 | 186 | uint16_t get_num_children() const { return static_cast<uint16_t>(_children.size()); } |
183 | | |
184 | 222 | virtual bool is_rf_wrapper() const { |
185 | 222 | return std::ranges::any_of(_children.begin(), _children.end(), |
186 | 222 | [](VExprSPtr child) { return child->is_rf_wrapper(); }); |
187 | 222 | } |
188 | | |
189 | 0 | virtual void do_judge_selectivity(uint64_t filter_rows, uint64_t input_rows) { |
190 | 0 | for (auto child : _children) { |
191 | 0 | child->do_judge_selectivity(filter_rows, input_rows); |
192 | 0 | } |
193 | 0 | } |
194 | | |
195 | | static Status create_expr_tree(const TExpr& texpr, VExprContextSPtr& ctx); |
196 | | |
197 | | static Status create_expr_trees(const std::vector<TExpr>& texprs, VExprContextSPtrs& ctxs); |
198 | | |
199 | | static Status prepare(const VExprContextSPtrs& ctxs, RuntimeState* state, |
200 | | const RowDescriptor& row_desc); |
201 | | |
202 | | static Status open(const VExprContextSPtrs& ctxs, RuntimeState* state); |
203 | | |
204 | | static Status clone_if_not_exists(const VExprContextSPtrs& ctxs, RuntimeState* state, |
205 | | VExprContextSPtrs& new_ctxs); |
206 | | |
207 | 96.2k | static bool contains_blockable_function(const VExprContextSPtrs& ctxs) { |
208 | 96.2k | return std::any_of(ctxs.begin(), ctxs.end(), |
209 | 96.2k | [](const VExprContextSPtr& ctx) { return ctx->root()->is_blockable(); }); |
210 | 96.2k | } |
211 | | |
212 | 47 | bool is_nullable() const { return _data_type->is_nullable(); } |
213 | | |
214 | 0 | PrimitiveType result_type() const { return _data_type->get_primitive_type(); } |
215 | | |
216 | | static Status create_expr(const TExprNode& expr_node, VExprSPtr& expr); |
217 | | |
218 | | static Status create_tree_from_thrift(const std::vector<TExprNode>& nodes, int* node_idx, |
219 | | VExprSPtr& root_expr, VExprContextSPtr& ctx); |
220 | | |
221 | | static Status check_expr_output_type(const VExprContextSPtrs& ctxs, |
222 | | const RowDescriptor& output_row_desc); |
223 | 5.24k | virtual const VExprSPtrs& children() const { return _children; } |
224 | 0 | void set_children(const VExprSPtrs& children) { _children = children; } |
225 | 0 | void set_children(VExprSPtrs&& children) { _children = std::move(children); } |
226 | | virtual std::string debug_string() const; |
227 | | static std::string debug_string(const VExprSPtrs& exprs); |
228 | | static std::string debug_string(const VExprContextSPtrs& ctxs); |
229 | | |
230 | 0 | void set_getting_const_col(bool val = true) { _getting_const_col = val; } |
231 | | |
232 | 83 | bool is_and_expr() const { return _fn.name.function_name == "and"; } |
233 | | |
234 | 0 | virtual bool is_compound_predicate() const { return false; } |
235 | | |
236 | 303 | const TFunction& fn() const { return _fn; } |
237 | | |
238 | | /// Returns true if expr doesn't contain slotrefs, i.e., can be evaluated |
239 | | /// with get_value(NULL). The default implementation returns true if all of |
240 | | /// the children are constant. |
241 | | virtual bool is_constant() const; |
242 | | |
243 | | /// If this expr is constant, evaluates the expr with no input row argument and returns |
244 | | /// the output. Returns nullptr if the argument is not constant. The returned ColumnPtr is |
245 | | /// owned by this expr. This should only be called after Open() has been called on this |
246 | | /// expr. |
247 | | MOCK_FUNCTION Status get_const_col(VExprContext* context, |
248 | | std::shared_ptr<ColumnPtrWrapper>* column_wrapper); |
249 | | |
250 | 22 | int fn_context_index() const { return _fn_context_index; } |
251 | | |
252 | 537 | static VExprSPtr expr_without_cast(const VExprSPtr& expr) { |
253 | 537 | if (expr->node_type() == TExprNodeType::CAST_EXPR) { |
254 | 5 | return expr_without_cast(expr->_children[0]); |
255 | 5 | } |
256 | 532 | return expr; |
257 | 537 | } |
258 | | |
259 | | // If this expr is a RuntimeFilterWrapper, this method will return an underlying rf expression |
260 | 83 | virtual VExprSPtr get_impl() const { return {}; } |
261 | | |
262 | | // If this expr is a BloomPredicate, this method will return a BloomFilterFunc |
263 | 0 | virtual std::shared_ptr<BloomFilterFuncBase> get_bloom_filter_func() const { |
264 | 0 | throw Exception(Status::FatalError( |
265 | 0 | "Method 'get_bloom_filter_func()' is not supported in expression: {}", |
266 | 0 | this->debug_string())); |
267 | 0 | } |
268 | | |
269 | 13 | virtual std::shared_ptr<HybridSetBase> get_set_func() const { return nullptr; } |
270 | | |
271 | | // If this expr is a BitmapPredicate, this method will return a BitmapFilterFunc |
272 | 0 | virtual std::shared_ptr<BitmapFilterFuncBase> get_bitmap_filter_func() const { |
273 | 0 | throw Exception(Status::FatalError( |
274 | 0 | "Method 'get_bitmap_filter_func()' is not supported in expression: {}", |
275 | 0 | this->debug_string())); |
276 | 0 | } |
277 | | |
278 | | // fast_execute can direct copy expr filter result which build by apply index in segment_iterator |
279 | | bool fast_execute(doris::vectorized::VExprContext* context, doris::vectorized::Block* block, |
280 | | int* result_column_id); |
281 | | |
282 | 0 | virtual bool can_push_down_to_index() const { return false; } |
283 | | virtual bool equals(const VExpr& other); |
284 | 0 | void set_index_unique_id(uint32_t index_unique_id) { _index_unique_id = index_unique_id; } |
285 | 0 | uint32_t index_unique_id() const { return _index_unique_id; } |
286 | | |
287 | 20 | virtual void collect_slot_column_ids(std::set<int>& column_ids) const { |
288 | 24 | for (auto child : _children) { |
289 | 24 | child->collect_slot_column_ids(column_ids); |
290 | 24 | } |
291 | 20 | } |
292 | | |
293 | | #ifdef BE_TEST |
294 | 4 | void set_node_type(TExprNodeType::type node_type) { _node_type = node_type; } |
295 | | #endif |
296 | | virtual Status evaluate_ann_range_search( |
297 | | const segment_v2::AnnRangeSearchRuntime& runtime, |
298 | | const std::vector<std::unique_ptr<segment_v2::IndexIterator>>& cid_to_index_iterators, |
299 | | const std::vector<ColumnId>& idx_to_cid, |
300 | | const std::vector<std::unique_ptr<segment_v2::ColumnIterator>>& column_iterators, |
301 | | roaring::Roaring& row_bitmap, segment_v2::AnnIndexStats& ann_index_stats); |
302 | | |
303 | | // Prepare the runtime for ANN range search. |
304 | | // AnnRangeSearchRuntime is used to store the runtime information of ann range search. |
305 | | // suitable_for_ann_index is used to indicate whether the current expr can be used for ANN range search. |
306 | | // If suitable_for_ann_index is false, the we will do exhausted search. |
307 | | virtual void prepare_ann_range_search(const doris::VectorSearchUserParams& params, |
308 | | segment_v2::AnnRangeSearchRuntime& range_search_runtime, |
309 | | bool& suitable_for_ann_index); |
310 | | |
311 | | bool has_been_executed(); |
312 | | |
313 | | protected: |
314 | | /// Simple debug string that provides no expr subclass-specific information |
315 | 0 | std::string debug_string(const std::string& expr_name) const { |
316 | 0 | std::stringstream out; |
317 | 0 | out << expr_name << "(" << VExpr::debug_string() << ")"; |
318 | 0 | return out.str(); |
319 | 0 | } |
320 | | |
321 | | // used in expr name |
322 | 90 | std::string get_child_names() { |
323 | 90 | std::string res; |
324 | 139 | for (auto child : _children) { |
325 | 139 | if (!res.empty()) { |
326 | 52 | res += ", "; |
327 | 52 | } |
328 | 139 | res += child->expr_name(); |
329 | 139 | } |
330 | 90 | return res; |
331 | 90 | } |
332 | | |
333 | | // only for errmsg now |
334 | 0 | std::string get_child_type_names() { |
335 | 0 | std::string res; |
336 | 0 | for (auto child : _children) { |
337 | 0 | if (!res.empty()) { |
338 | 0 | res += ", "; |
339 | 0 | } |
340 | 0 | res += child->expr_name() + ": " + child->data_type()->get_name(); |
341 | 0 | } |
342 | 0 | return res; |
343 | 0 | } |
344 | | |
345 | 14 | bool is_const_and_have_executed() { return (is_constant() && (_constant_col != nullptr)); } |
346 | | |
347 | | Status get_result_from_const(vectorized::Block* block, const std::string& expr_name, |
348 | | int* result_column_id); |
349 | | |
350 | | Status check_constant(const Block& block, ColumnNumbers arguments) const; |
351 | | |
352 | | /// Helper function that calls ctx->register(), sets fn_context_index_, and returns the |
353 | | /// registered FunctionContext |
354 | | void register_function_context(RuntimeState* state, VExprContext* context); |
355 | | |
356 | | /// Helper function to initialize function context, called in `open` phase of VExpr: |
357 | | /// 1. Set constant columns result of function arguments. |
358 | | /// 2. Call function's prepare() to initialize function state, fragment-local or |
359 | | /// thread-local according the input `FunctionStateScope` argument. |
360 | | Status init_function_context(RuntimeState* state, VExprContext* context, |
361 | | FunctionContext::FunctionStateScope scope, |
362 | | const FunctionBasePtr& function) const; |
363 | | |
364 | | /// Helper function to close function context, fragment-local or thread-local according |
365 | | /// the input `FunctionStateScope` argument. Called in `close` phase of VExpr. |
366 | | void close_function_context(VExprContext* context, FunctionContext::FunctionStateScope scope, |
367 | | const FunctionBasePtr& function) const; |
368 | | |
369 | | TExprNodeType::type _node_type; |
370 | | // Used to check what opcode |
371 | | TExprOpcode::type _opcode; |
372 | | DataTypePtr _data_type; |
373 | | VExprSPtrs _children; // in few hundreds |
374 | | TFunction _fn; |
375 | | |
376 | | /// Index to pass to ExprContext::fn_context() to retrieve this expr's FunctionContext. |
377 | | /// Set in RegisterFunctionContext(). -1 if this expr does not need a FunctionContext and |
378 | | /// doesn't call RegisterFunctionContext(). |
379 | | int _fn_context_index = -1; |
380 | | |
381 | | // If this expr is constant, this will store and cache the value generated by |
382 | | // get_const_col() |
383 | | std::shared_ptr<ColumnPtrWrapper> _constant_col; |
384 | | bool _prepared = false; // for base class VExpr |
385 | | bool _getting_const_col = |
386 | | false; // if true, current execute() is in prepare() (that is, can't check _prepared) |
387 | | // for concrete classes |
388 | | bool _prepare_finished = false; |
389 | | bool _open_finished = false; |
390 | | |
391 | | // ensuring uniqueness during index traversal |
392 | | uint32_t _index_unique_id = 0; |
393 | | bool _enable_inverted_index_query = true; |
394 | | |
395 | | bool _has_been_executed = false; |
396 | | }; |
397 | | |
398 | | } // namespace vectorized |
399 | | |
400 | | // NOLINTBEGIN(readability-function-size) |
401 | | template <PrimitiveType T> |
402 | | Status create_texpr_literal_node(const void* data, TExprNode* node, int precision = 0, |
403 | 38 | int scale = 0) { |
404 | 38 | if constexpr (T == TYPE_BOOLEAN) { |
405 | 1 | const auto* origin_value = reinterpret_cast<const bool*>(data); |
406 | 1 | TBoolLiteral boolLiteral; |
407 | 1 | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); |
408 | 1 | boolLiteral.__set_value(*origin_value); |
409 | 1 | (*node).__set_bool_literal(boolLiteral); |
410 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); |
411 | 1 | } else if constexpr (T == TYPE_TINYINT) { |
412 | 0 | const auto* origin_value = reinterpret_cast<const int8_t*>(data); |
413 | 0 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
414 | 0 | TIntLiteral intLiteral; |
415 | 0 | intLiteral.__set_value(*origin_value); |
416 | 0 | (*node).__set_int_literal(intLiteral); |
417 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); |
418 | 1 | } else if constexpr (T == TYPE_SMALLINT) { |
419 | 1 | const auto* origin_value = reinterpret_cast<const int16_t*>(data); |
420 | 1 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
421 | 1 | TIntLiteral intLiteral; |
422 | 1 | intLiteral.__set_value(*origin_value); |
423 | 1 | (*node).__set_int_literal(intLiteral); |
424 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); |
425 | 6 | } else if constexpr (T == TYPE_INT) { |
426 | 6 | const auto* origin_value = reinterpret_cast<const int32_t*>(data); |
427 | 6 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
428 | 6 | TIntLiteral intLiteral; |
429 | 6 | intLiteral.__set_value(*origin_value); |
430 | 6 | (*node).__set_int_literal(intLiteral); |
431 | 6 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); |
432 | 12 | } else if constexpr (T == TYPE_BIGINT) { |
433 | 12 | const auto* origin_value = reinterpret_cast<const int64_t*>(data); |
434 | 12 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); |
435 | 12 | TIntLiteral intLiteral; |
436 | 12 | intLiteral.__set_value(*origin_value); |
437 | 12 | (*node).__set_int_literal(intLiteral); |
438 | 12 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); |
439 | 12 | } else if constexpr (T == TYPE_LARGEINT) { |
440 | 1 | const auto* origin_value = reinterpret_cast<const int128_t*>(data); |
441 | 1 | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); |
442 | 1 | TLargeIntLiteral large_int_literal; |
443 | 1 | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); |
444 | 1 | (*node).__set_large_int_literal(large_int_literal); |
445 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); |
446 | 2 | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { |
447 | 2 | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); |
448 | 2 | TDateLiteral date_literal; |
449 | 2 | char convert_buffer[30]; |
450 | 2 | origin_value->to_string(convert_buffer); |
451 | 2 | date_literal.__set_value(convert_buffer); |
452 | 2 | (*node).__set_date_literal(date_literal); |
453 | 2 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); |
454 | 2 | if (origin_value->type() == TimeType::TIME_DATE) { |
455 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); |
456 | 1 | } else if (origin_value->type() == TimeType::TIME_DATETIME) { |
457 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); |
458 | 1 | } |
459 | 2 | } else if constexpr (T == TYPE_DATEV2) { |
460 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); |
468 | 1 | } else if constexpr (T == TYPE_DATETIMEV2) { |
469 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); |
470 | 1 | TDateLiteral date_literal; |
471 | 1 | char convert_buffer[30]; |
472 | 1 | origin_value->to_string(convert_buffer, scale); |
473 | 1 | date_literal.__set_value(convert_buffer); |
474 | 1 | (*node).__set_date_literal(date_literal); |
475 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); |
476 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); |
477 | 1 | } else if constexpr (T == TYPE_DECIMALV2) { |
478 | 1 | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); |
479 | 1 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
480 | 1 | TDecimalLiteral decimal_literal; |
481 | 1 | decimal_literal.__set_value(origin_value->to_string()); |
482 | 1 | (*node).__set_decimal_literal(decimal_literal); |
483 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); |
484 | 2 | } else if constexpr (T == TYPE_DECIMAL32) { |
485 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); |
486 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
487 | 2 | TDecimalLiteral decimal_literal; |
488 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
489 | 2 | (*node).__set_decimal_literal(decimal_literal); |
490 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); |
491 | 2 | } else if constexpr (T == TYPE_DECIMAL64) { |
492 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); |
493 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
494 | 2 | TDecimalLiteral decimal_literal; |
495 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
496 | 2 | (*node).__set_decimal_literal(decimal_literal); |
497 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); |
498 | 2 | } else if constexpr (T == TYPE_DECIMAL128I) { |
499 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); |
500 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
501 | 2 | TDecimalLiteral decimal_literal; |
502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF |
503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the |
504 | | // final min value of the MinMax RF if the fragment instance has no data. |
505 | | // Need to truncate the value to the right precision and scale here, to avoid |
506 | | // error when casting string back to decimal later. |
507 | | // TODO: this is a temporary solution, the best solution is to produce the |
508 | | // right min max value at the producer side. |
509 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
510 | 2 | (*node).__set_decimal_literal(decimal_literal); |
511 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); |
512 | 2 | } else if constexpr (T == TYPE_DECIMAL256) { |
513 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); |
514 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); |
515 | 2 | TDecimalLiteral decimal_literal; |
516 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); |
517 | 2 | (*node).__set_decimal_literal(decimal_literal); |
518 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); |
519 | 2 | } else if constexpr (T == TYPE_FLOAT) { |
520 | 1 | const auto* origin_value = reinterpret_cast<const float*>(data); |
521 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); |
522 | 1 | TFloatLiteral float_literal; |
523 | 1 | float_literal.__set_value(*origin_value); |
524 | 1 | (*node).__set_float_literal(float_literal); |
525 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); |
526 | 1 | } else if constexpr (T == TYPE_DOUBLE) { |
527 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); |
528 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); |
529 | 1 | TFloatLiteral float_literal; |
530 | 1 | float_literal.__set_value(*origin_value); |
531 | 1 | (*node).__set_float_literal(float_literal); |
532 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); |
533 | 1 | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { |
534 | 1 | const auto* origin_value = reinterpret_cast<const std::string*>(data); |
535 | 1 | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); |
536 | 1 | TStringLiteral string_literal; |
537 | 1 | string_literal.__set_value(*origin_value); |
538 | 1 | (*node).__set_string_literal(string_literal); |
539 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); |
540 | 1 | } else if constexpr (T == TYPE_IPV4) { |
541 | 0 | const auto* origin_value = reinterpret_cast<const IPv4*>(data); |
542 | 0 | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); |
543 | 0 | TIPv4Literal literal; |
544 | 0 | literal.__set_value(*origin_value); |
545 | 0 | (*node).__set_ipv4_literal(literal); |
546 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); |
547 | 0 | } else if constexpr (T == TYPE_IPV6) { |
548 | 0 | const auto* origin_value = reinterpret_cast<const IPv6*>(data); |
549 | 0 | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); |
550 | 0 | TIPv6Literal literal; |
551 | 0 | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); |
552 | 0 | (*node).__set_ipv6_literal(literal); |
553 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); |
554 | 1 | } else if constexpr (T == TYPE_TIMEV2) { |
555 | | // the code use for runtime filter but we dont support timev2 as predicate now |
556 | | // so this part not used |
557 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); |
558 | 1 | TTimeV2Literal timev2_literal; |
559 | 1 | timev2_literal.__set_value(*origin_value); |
560 | 1 | (*node).__set_timev2_literal(timev2_literal); |
561 | 1 | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); |
562 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); |
563 | | } else { |
564 | | return Status::InvalidArgument("Invalid argument type!"); |
565 | | } |
566 | 38 | return Status::OK(); |
567 | 38 | } _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE2EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | 1 | if constexpr (T == TYPE_BOOLEAN) { | 405 | 1 | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | 1 | TBoolLiteral boolLiteral; | 407 | 1 | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | 1 | boolLiteral.__set_value(*origin_value); | 409 | 1 | (*node).__set_bool_literal(boolLiteral); | 410 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE3EEENS_6StatusEPKvPNS_9TExprNodeEii _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE4EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | 1 | } else if constexpr (T == TYPE_SMALLINT) { | 419 | 1 | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | 1 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | 1 | TIntLiteral intLiteral; | 422 | 1 | intLiteral.__set_value(*origin_value); | 423 | 1 | (*node).__set_int_literal(intLiteral); | 424 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE5EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 6 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | 6 | } else if constexpr (T == TYPE_INT) { | 426 | 6 | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | 6 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | 6 | TIntLiteral intLiteral; | 429 | 6 | intLiteral.__set_value(*origin_value); | 430 | 6 | (*node).__set_int_literal(intLiteral); | 431 | 6 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 6 | return Status::OK(); | 567 | 6 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE6EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 12 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | 12 | } else if constexpr (T == TYPE_BIGINT) { | 433 | 12 | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | 12 | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | 12 | TIntLiteral intLiteral; | 436 | 12 | intLiteral.__set_value(*origin_value); | 437 | 12 | (*node).__set_int_literal(intLiteral); | 438 | 12 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 12 | return Status::OK(); | 567 | 12 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE7EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | 1 | } else if constexpr (T == TYPE_LARGEINT) { | 440 | 1 | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | 1 | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | 1 | TLargeIntLiteral large_int_literal; | 443 | 1 | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | 1 | (*node).__set_large_int_literal(large_int_literal); | 445 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE8EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | 1 | } else if constexpr (T == TYPE_FLOAT) { | 520 | 1 | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | 1 | TFloatLiteral float_literal; | 523 | 1 | float_literal.__set_value(*origin_value); | 524 | 1 | (*node).__set_float_literal(float_literal); | 525 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE9EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | 1 | } else if constexpr (T == TYPE_DOUBLE) { | 527 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | 1 | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | 1 | TFloatLiteral float_literal; | 530 | 1 | float_literal.__set_value(*origin_value); | 531 | 1 | (*node).__set_float_literal(float_literal); | 532 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE25EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | 1 | } else if constexpr (T == TYPE_DATEV2) { | 460 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE26EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | 1 | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | 1 | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | 1 | TDateLiteral date_literal; | 471 | 1 | char convert_buffer[30]; | 472 | 1 | origin_value->to_string(convert_buffer, scale); | 473 | 1 | date_literal.__set_value(convert_buffer); | 474 | 1 | (*node).__set_date_literal(date_literal); | 475 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE11EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | 1 | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | 1 | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | 1 | TDateLiteral date_literal; | 449 | 1 | char convert_buffer[30]; | 450 | 1 | origin_value->to_string(convert_buffer); | 451 | 1 | date_literal.__set_value(convert_buffer); | 452 | 1 | (*node).__set_date_literal(date_literal); | 453 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | 1 | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | 1 | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | 0 | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE12EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | 1 | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | 1 | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | 1 | TDateLiteral date_literal; | 449 | 1 | char convert_buffer[30]; | 450 | 1 | origin_value->to_string(convert_buffer); | 451 | 1 | date_literal.__set_value(convert_buffer); | 452 | 1 | (*node).__set_date_literal(date_literal); | 453 | 1 | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | 1 | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | 0 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | 1 | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | 1 | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE20EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | 1 | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | 1 | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | 1 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | 1 | TDecimalLiteral decimal_literal; | 481 | 1 | decimal_literal.__set_value(origin_value->to_string()); | 482 | 1 | (*node).__set_decimal_literal(decimal_literal); | 483 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE28EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 2 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | 2 | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | 2 | TDecimalLiteral decimal_literal; | 488 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | 2 | (*node).__set_decimal_literal(decimal_literal); | 490 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 2 | return Status::OK(); | 567 | 2 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE29EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 2 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | 2 | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | 2 | TDecimalLiteral decimal_literal; | 495 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | 2 | (*node).__set_decimal_literal(decimal_literal); | 497 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 2 | return Status::OK(); | 567 | 2 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE30EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 2 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | 2 | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | 2 | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | 2 | (*node).__set_decimal_literal(decimal_literal); | 511 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 2 | return Status::OK(); | 567 | 2 | } |
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE35EEENS_6StatusEPKvPNS_9TExprNodeEii Line | Count | Source | 403 | 2 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | 2 | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | 2 | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | 2 | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | 2 | TDecimalLiteral decimal_literal; | 516 | 2 | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | 2 | (*node).__set_decimal_literal(decimal_literal); | 518 | 2 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 2 | return Status::OK(); | 567 | 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 | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | 1 | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | 1 | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | 1 | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | 1 | TStringLiteral string_literal; | 537 | 1 | string_literal.__set_value(*origin_value); | 538 | 1 | (*node).__set_string_literal(string_literal); | 539 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | | TTimeV2Literal timev2_literal; | 559 | | timev2_literal.__set_value(*origin_value); | 560 | | (*node).__set_timev2_literal(timev2_literal); | 561 | | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 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 | 403 | 1 | int scale = 0) { | 404 | | if constexpr (T == TYPE_BOOLEAN) { | 405 | | const auto* origin_value = reinterpret_cast<const bool*>(data); | 406 | | TBoolLiteral boolLiteral; | 407 | | (*node).__set_node_type(TExprNodeType::BOOL_LITERAL); | 408 | | boolLiteral.__set_value(*origin_value); | 409 | | (*node).__set_bool_literal(boolLiteral); | 410 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN)); | 411 | | } else if constexpr (T == TYPE_TINYINT) { | 412 | | const auto* origin_value = reinterpret_cast<const int8_t*>(data); | 413 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 414 | | TIntLiteral intLiteral; | 415 | | intLiteral.__set_value(*origin_value); | 416 | | (*node).__set_int_literal(intLiteral); | 417 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT)); | 418 | | } else if constexpr (T == TYPE_SMALLINT) { | 419 | | const auto* origin_value = reinterpret_cast<const int16_t*>(data); | 420 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 421 | | TIntLiteral intLiteral; | 422 | | intLiteral.__set_value(*origin_value); | 423 | | (*node).__set_int_literal(intLiteral); | 424 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT)); | 425 | | } else if constexpr (T == TYPE_INT) { | 426 | | const auto* origin_value = reinterpret_cast<const int32_t*>(data); | 427 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 428 | | TIntLiteral intLiteral; | 429 | | intLiteral.__set_value(*origin_value); | 430 | | (*node).__set_int_literal(intLiteral); | 431 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT)); | 432 | | } else if constexpr (T == TYPE_BIGINT) { | 433 | | const auto* origin_value = reinterpret_cast<const int64_t*>(data); | 434 | | (*node).__set_node_type(TExprNodeType::INT_LITERAL); | 435 | | TIntLiteral intLiteral; | 436 | | intLiteral.__set_value(*origin_value); | 437 | | (*node).__set_int_literal(intLiteral); | 438 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT)); | 439 | | } else if constexpr (T == TYPE_LARGEINT) { | 440 | | const auto* origin_value = reinterpret_cast<const int128_t*>(data); | 441 | | (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL); | 442 | | TLargeIntLiteral large_int_literal; | 443 | | large_int_literal.__set_value(LargeIntValue::to_string(*origin_value)); | 444 | | (*node).__set_large_int_literal(large_int_literal); | 445 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT)); | 446 | | } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) { | 447 | | const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data); | 448 | | TDateLiteral date_literal; | 449 | | char convert_buffer[30]; | 450 | | origin_value->to_string(convert_buffer); | 451 | | date_literal.__set_value(convert_buffer); | 452 | | (*node).__set_date_literal(date_literal); | 453 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 454 | | if (origin_value->type() == TimeType::TIME_DATE) { | 455 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE)); | 456 | | } else if (origin_value->type() == TimeType::TIME_DATETIME) { | 457 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME)); | 458 | | } | 459 | | } else if constexpr (T == TYPE_DATEV2) { | 460 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(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 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2)); | 468 | | } else if constexpr (T == TYPE_DATETIMEV2) { | 469 | | const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data); | 470 | | TDateLiteral date_literal; | 471 | | char convert_buffer[30]; | 472 | | origin_value->to_string(convert_buffer, scale); | 473 | | date_literal.__set_value(convert_buffer); | 474 | | (*node).__set_date_literal(date_literal); | 475 | | (*node).__set_node_type(TExprNodeType::DATE_LITERAL); | 476 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale)); | 477 | | } else if constexpr (T == TYPE_DECIMALV2) { | 478 | | const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data); | 479 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 480 | | TDecimalLiteral decimal_literal; | 481 | | decimal_literal.__set_value(origin_value->to_string()); | 482 | | (*node).__set_decimal_literal(decimal_literal); | 483 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale)); | 484 | | } else if constexpr (T == TYPE_DECIMAL32) { | 485 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int32_t>*>(data); | 486 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 487 | | TDecimalLiteral decimal_literal; | 488 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 489 | | (*node).__set_decimal_literal(decimal_literal); | 490 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale)); | 491 | | } else if constexpr (T == TYPE_DECIMAL64) { | 492 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int64_t>*>(data); | 493 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 494 | | TDecimalLiteral decimal_literal; | 495 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 496 | | (*node).__set_decimal_literal(decimal_literal); | 497 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale)); | 498 | | } else if constexpr (T == TYPE_DECIMAL128I) { | 499 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<int128_t>*>(data); | 500 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 501 | | TDecimalLiteral decimal_literal; | 502 | | // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF | 503 | | // on the RF producer side is an int128 value with 38 digits of 9, and this is the | 504 | | // final min value of the MinMax RF if the fragment instance has no data. | 505 | | // Need to truncate the value to the right precision and scale here, to avoid | 506 | | // error when casting string back to decimal later. | 507 | | // TODO: this is a temporary solution, the best solution is to produce the | 508 | | // right min max value at the producer side. | 509 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 510 | | (*node).__set_decimal_literal(decimal_literal); | 511 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale)); | 512 | | } else if constexpr (T == TYPE_DECIMAL256) { | 513 | | const auto* origin_value = reinterpret_cast<const vectorized::Decimal<wide::Int256>*>(data); | 514 | | (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL); | 515 | | TDecimalLiteral decimal_literal; | 516 | | decimal_literal.__set_value(origin_value->to_string(precision, scale)); | 517 | | (*node).__set_decimal_literal(decimal_literal); | 518 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale)); | 519 | | } else if constexpr (T == TYPE_FLOAT) { | 520 | | const auto* origin_value = reinterpret_cast<const float*>(data); | 521 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 522 | | TFloatLiteral float_literal; | 523 | | float_literal.__set_value(*origin_value); | 524 | | (*node).__set_float_literal(float_literal); | 525 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT)); | 526 | | } else if constexpr (T == TYPE_DOUBLE) { | 527 | | const auto* origin_value = reinterpret_cast<const double*>(data); | 528 | | (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL); | 529 | | TFloatLiteral float_literal; | 530 | | float_literal.__set_value(*origin_value); | 531 | | (*node).__set_float_literal(float_literal); | 532 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE)); | 533 | | } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) { | 534 | | const auto* origin_value = reinterpret_cast<const std::string*>(data); | 535 | | (*node).__set_node_type(TExprNodeType::STRING_LITERAL); | 536 | | TStringLiteral string_literal; | 537 | | string_literal.__set_value(*origin_value); | 538 | | (*node).__set_string_literal(string_literal); | 539 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING)); | 540 | | } else if constexpr (T == TYPE_IPV4) { | 541 | | const auto* origin_value = reinterpret_cast<const IPv4*>(data); | 542 | | (*node).__set_node_type(TExprNodeType::IPV4_LITERAL); | 543 | | TIPv4Literal literal; | 544 | | literal.__set_value(*origin_value); | 545 | | (*node).__set_ipv4_literal(literal); | 546 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4)); | 547 | | } else if constexpr (T == TYPE_IPV6) { | 548 | | const auto* origin_value = reinterpret_cast<const IPv6*>(data); | 549 | | (*node).__set_node_type(TExprNodeType::IPV6_LITERAL); | 550 | | TIPv6Literal literal; | 551 | | literal.__set_value(vectorized::CastToString::from_ip(*origin_value)); | 552 | | (*node).__set_ipv6_literal(literal); | 553 | | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6)); | 554 | 1 | } else if constexpr (T == TYPE_TIMEV2) { | 555 | | // the code use for runtime filter but we dont support timev2 as predicate now | 556 | | // so this part not used | 557 | 1 | const auto* origin_value = reinterpret_cast<const double*>(data); | 558 | 1 | TTimeV2Literal timev2_literal; | 559 | 1 | timev2_literal.__set_value(*origin_value); | 560 | 1 | (*node).__set_timev2_literal(timev2_literal); | 561 | 1 | (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL); | 562 | 1 | (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale)); | 563 | | } else { | 564 | | return Status::InvalidArgument("Invalid argument type!"); | 565 | | } | 566 | 1 | return Status::OK(); | 567 | 1 | } |
|
568 | | // NOLINTEND(readability-function-size) |
569 | | |
570 | | TExprNode create_texpr_node_from(const void* data, const PrimitiveType& type, int precision = 0, |
571 | | int scale = 0); |
572 | | |
573 | | TExprNode create_texpr_node_from(const vectorized::Field& field, const PrimitiveType& type, |
574 | | int precision, int scale); |
575 | | |
576 | | #include "common/compile_check_end.h" |
577 | | } // namespace doris |