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