Coverage Report

Created: 2025-11-21 14:14

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