Coverage Report

Created: 2026-05-15 12:36

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