Coverage Report

Created: 2025-09-18 13:12

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