Coverage Report

Created: 2026-05-13 13:59

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.12M
    if (_prepared) {                      \
71
34
        return Status::OK();              \
72
34
    }                                     \
73
9.12M
    _prepared = true;                     \
74
9.12M
    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
143k
    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
143k
        elem.column = elem.column->clone_resized(size);
89
143k
        block->insert(std::move(elem));
90
        // just inserted. so no need to check underflow.
91
143k
        return block->columns() - 1;
92
143k
    }
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.43M
    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
65.2k
    virtual Status execute(VExprContext* context, Block* block, int* result_column_id) const {
132
65.2k
        ColumnPtr result_column;
133
65.2k
        RETURN_IF_ERROR(execute_column(context, block, nullptr, block->rows(), result_column));
134
65.2k
        *result_column_id = block->columns();
135
65.2k
        block->insert({result_column, execute_type(block), expr_name()});
136
65.2k
        return Status::OK();
137
65.2k
    }
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.21M
    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.64M
    [[nodiscard]] virtual bool is_blockable() const {
164
4.64M
        return std::any_of(_children.begin(), _children.end(),
165
4.64M
                           [](VExprSPtr child) { return child->is_blockable(); });
166
4.64M
    }
167
168
    // execute current expr with inverted index to filter block. Given a roaring bitmap of match rows
169
1.87k
    virtual Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) {
170
1.87k
        return Status::OK();
171
1.87k
    }
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.8M
    DataTypePtr& data_type() { return _data_type; }
200
201
7.46k
    const DataTypePtr& data_type() const { return _data_type; }
202
203
554k
    bool is_slot_ref() const { return _node_type == TExprNodeType::SLOT_REF; }
204
205
94.5k
    bool is_virtual_slot_ref() const { return _node_type == TExprNodeType::VIRTUAL_SLOT_REF; }
206
207
269
    bool is_column_ref() const { return _node_type == TExprNodeType::COLUMN_REF; }
208
209
741k
    virtual bool is_literal() const { return false; }
210
211
5.93M
    virtual TExprNodeType::type node_type() const { return _node_type; }
212
213
114k
    TExprOpcode::type op() const { return _opcode; }
214
215
1.75M
    void add_child(const VExprSPtr& expr) { _children.push_back(expr); }
216
51.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
568k
    uint16_t get_num_children() const { return static_cast<uint16_t>(_children.size()); }
220
221
7.28M
    virtual bool is_rf_wrapper() const {
222
7.28M
        return std::ranges::any_of(_children.begin(), _children.end(),
223
7.28M
                                   [](VExprSPtr child) { return child->is_rf_wrapper(); });
224
7.28M
    }
225
3.93k
    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
313k
    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.85M
    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.12M
                                                 const Selector* selector, size_t count) {
261
3.12M
        if (selector == nullptr) {
262
3.11M
            DCHECK_EQ(origin_column->size(), count);
263
3.11M
            return origin_column;
264
3.11M
        }
265
3.12M
        DCHECK_EQ(count, selector->size());
266
2.27k
        auto mutable_column = origin_column->clone_empty();
267
2.27k
        origin_column->append_data_by_selector(mutable_column, *selector);
268
2.27k
        DCHECK_EQ(mutable_column->size(), count);
269
2.27k
        return mutable_column;
270
3.12M
    }
271
272
0
    bool is_and_expr() const { return _fn.name.function_name == "and"; }
273
1.66k
    bool is_like_expr() const { return _fn.name.function_name == "like"; }
274
275
1.72M
    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.22k
    int fn_context_index() const { return _fn_context_index; }
290
291
2.67M
    static VExprSPtr expr_without_cast(const VExprSPtr& expr) {
292
2.67M
        if (expr->node_type() == TExprNodeType::CAST_EXPR) {
293
19.3k
            return expr_without_cast(expr->_children[0]);
294
19.3k
        }
295
2.65M
        return expr;
296
2.67M
    }
297
298
17.7k
    virtual double execute_cost() const {
299
17.7k
        double cost = 1.0;
300
21.0k
        for (const auto& child : _children) {
301
21.0k
            cost += child->execute_cost();
302
21.0k
        }
303
17.7k
        return cost;
304
17.7k
    }
305
306
    // If this expr is a RuntimeFilterWrapper, this method will return an underlying rf expression
307
29.7k
    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
3.03k
    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
162
    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.01k
    virtual void collect_slot_column_ids(std::set<int>& column_ids) const {
335
2.98k
        for (auto child : _children) {
336
2.98k
            child->collect_slot_column_ids(column_ids);
337
2.98k
        }
338
2.01k
    }
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
350
    // Prepare the runtime for ANN range search.
351
    // AnnRangeSearchRuntime is used to store the runtime information of ann range search.
352
    // suitable_for_ann_index is used to indicate whether the current expr can be used for ANN range search.
353
    // If suitable_for_ann_index is false, the we will do exhausted search.
354
    virtual void prepare_ann_range_search(const doris::VectorSearchUserParams& params,
355
                                          segment_v2::AnnRangeSearchRuntime& range_search_runtime,
356
                                          bool& suitable_for_ann_index);
357
358
    bool ann_range_search_executedd();
359
360
    bool ann_dist_is_fulfilled() const;
361
362
    virtual uint64_t get_digest(uint64_t seed) const;
363
364
protected:
365
    /// Simple debug string that provides no expr subclass-specific information
366
0
    std::string debug_string(const std::string& expr_name) const {
367
0
        std::stringstream out;
368
0
        out << expr_name << "(" << VExpr::debug_string() << ")";
369
0
        return out.str();
370
0
    }
371
372
    // used in expr name
373
717k
    std::string get_child_names() {
374
717k
        std::string res;
375
1.38M
        for (auto child : _children) {
376
1.38M
            if (!res.empty()) {
377
629k
                res += ", ";
378
629k
            }
379
1.38M
            res += child->expr_name();
380
1.38M
        }
381
717k
        return res;
382
717k
    }
383
384
    // only for errmsg now
385
2
    std::string get_child_type_names() {
386
2
        std::string res;
387
2
        for (auto child : _children) {
388
2
            if (!res.empty()) {
389
0
                res += ", ";
390
0
            }
391
2
            res += child->expr_name() + ": " + child->data_type()->get_name();
392
2
        }
393
2
        return res;
394
2
    }
395
396
1.05M
    bool is_const_and_have_executed() const {
397
1.05M
        return (is_constant() && (_constant_col != nullptr));
398
1.05M
    }
399
400
    ColumnPtr get_result_from_const(size_t count) const;
401
402
    Status check_constant(const Block& block, ColumnNumbers arguments) const;
403
404
    /// Helper function that calls ctx->register(), sets fn_context_index_, and returns the
405
    /// registered FunctionContext
406
    void register_function_context(RuntimeState* state, VExprContext* context);
407
408
    /// Helper function to initialize function context, called in `open` phase of VExpr:
409
    /// 1. Set constant columns result of function arguments.
410
    /// 2. Call function's prepare() to initialize function state, fragment-local or
411
    /// thread-local according the input `FunctionStateScope` argument.
412
    Status init_function_context(RuntimeState* state, VExprContext* context,
413
                                 FunctionContext::FunctionStateScope scope,
414
                                 const FunctionBasePtr& function) const;
415
416
    /// Helper function to close function context, fragment-local or thread-local according
417
    /// the input `FunctionStateScope` argument. Called in `close` phase of VExpr.
418
    void close_function_context(VExprContext* context, FunctionContext::FunctionStateScope scope,
419
                                const FunctionBasePtr& function) const;
420
421
    TExprNodeType::type _node_type;
422
    // Used to check what opcode
423
    TExprOpcode::type _opcode;
424
    DataTypePtr _data_type;
425
    VExprSPtrs _children; // in few hundreds
426
    TFunction _fn;
427
428
    /// Index to pass to ExprContext::fn_context() to retrieve this expr's FunctionContext.
429
    /// Set in RegisterFunctionContext(). -1 if this expr does not need a FunctionContext and
430
    /// doesn't call RegisterFunctionContext().
431
    int _fn_context_index = -1;
432
433
    // If this expr is constant, this will store and cache the value generated by
434
    // get_const_col()
435
    std::shared_ptr<ColumnPtrWrapper> _constant_col;
436
    bool _prepared = false; // for base class VExpr
437
    // for concrete classes
438
    bool _prepare_finished = false;
439
    bool _open_finished = false;
440
441
    // ensuring uniqueness during index traversal
442
    uint32_t _index_unique_id = 0;
443
    bool _enable_inverted_index_query = true;
444
445
    // Indicates whether the expr row_bitmap has been updated.
446
    bool _has_been_executed = false;
447
    // Indicates whether the virtual column is fulfilled.
448
    // NOTE, if there is no virtual column in the expr tree, and expr
449
    // is evaluated by ann index, this flag is still true.
450
    bool _virtual_column_is_fulfilled = false;
451
};
452
453
// NOLINTBEGIN(readability-function-size)
454
template <PrimitiveType T>
455
Status create_texpr_literal_node(const void* data, TExprNode* node, int precision = 0,
456
32.2k
                                 int scale = 0) {
457
32.2k
    if constexpr (T == TYPE_BOOLEAN) {
458
89
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
89
        TBoolLiteral boolLiteral;
460
89
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
89
        boolLiteral.__set_value(*origin_value);
462
89
        (*node).__set_bool_literal(boolLiteral);
463
89
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
535
    } else if constexpr (T == TYPE_TINYINT) {
465
535
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
535
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
535
        TIntLiteral intLiteral;
468
535
        intLiteral.__set_value(*origin_value);
469
535
        (*node).__set_int_literal(intLiteral);
470
535
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
535
    } else if constexpr (T == TYPE_SMALLINT) {
472
285
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
285
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
285
        TIntLiteral intLiteral;
475
285
        intLiteral.__set_value(*origin_value);
476
285
        (*node).__set_int_literal(intLiteral);
477
285
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
7.78k
    } else if constexpr (T == TYPE_INT) {
479
7.78k
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
7.78k
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
7.78k
        TIntLiteral intLiteral;
482
7.78k
        intLiteral.__set_value(*origin_value);
483
7.78k
        (*node).__set_int_literal(intLiteral);
484
7.78k
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
18.6k
    } else if constexpr (T == TYPE_BIGINT) {
486
18.6k
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
18.6k
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
18.6k
        TIntLiteral intLiteral;
489
18.6k
        intLiteral.__set_value(*origin_value);
490
18.6k
        (*node).__set_int_literal(intLiteral);
491
18.6k
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
18.6k
    } else if constexpr (T == TYPE_LARGEINT) {
493
38
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
38
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
38
        TLargeIntLiteral large_int_literal;
496
38
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
38
        (*node).__set_large_int_literal(large_int_literal);
498
38
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
38
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
20
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
20
        TDateLiteral date_literal;
502
20
        char convert_buffer[30];
503
20
        origin_value->to_string(convert_buffer);
504
20
        date_literal.__set_value(convert_buffer);
505
20
        (*node).__set_date_literal(date_literal);
506
20
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
20
        if (origin_value->type() == TimeType::TIME_DATE) {
508
1
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
19
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
19
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
19
        }
512
344
    } else if constexpr (T == TYPE_DATEV2) {
513
344
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
344
        TDateLiteral date_literal;
515
344
        char convert_buffer[30];
516
344
        origin_value->to_string(convert_buffer);
517
344
        date_literal.__set_value(convert_buffer);
518
344
        (*node).__set_date_literal(date_literal);
519
344
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
344
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
948
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
948
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
948
        TDateLiteral date_literal;
524
948
        char convert_buffer[30];
525
948
        origin_value->to_string(convert_buffer, scale);
526
948
        date_literal.__set_value(convert_buffer);
527
948
        (*node).__set_date_literal(date_literal);
528
948
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
948
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
948
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
6
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
6
        TDateLiteral date_literal;
533
6
        auto tz = cctz::utc_time_zone();
534
6
        auto tz_str = origin_value->to_string(tz, scale);
535
6
        date_literal.__set_value(tz_str);
536
6
        (*node).__set_date_literal(date_literal);
537
6
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
6
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
6
    } else if constexpr (T == TYPE_DECIMALV2) {
540
5
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
5
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
5
        TDecimalLiteral decimal_literal;
543
5
        decimal_literal.__set_value(origin_value->to_string());
544
5
        (*node).__set_decimal_literal(decimal_literal);
545
5
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
16
    } else if constexpr (T == TYPE_DECIMAL32) {
547
16
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
16
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
16
        TDecimalLiteral decimal_literal;
550
16
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
16
        (*node).__set_decimal_literal(decimal_literal);
552
16
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
1.94k
    } else if constexpr (T == TYPE_DECIMAL64) {
554
1.94k
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
1.94k
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
1.94k
        TDecimalLiteral decimal_literal;
557
1.94k
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
1.94k
        (*node).__set_decimal_literal(decimal_literal);
559
1.94k
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
1.94k
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
94
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
94
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
94
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
94
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
94
        (*node).__set_decimal_literal(decimal_literal);
573
94
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
94
    } else if constexpr (T == TYPE_DECIMAL256) {
575
65
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
65
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
65
        TDecimalLiteral decimal_literal;
578
65
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
65
        (*node).__set_decimal_literal(decimal_literal);
580
65
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
65
    } else if constexpr (T == TYPE_FLOAT) {
582
65
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
65
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
65
        TFloatLiteral float_literal;
585
65
        float_literal.__set_value(*origin_value);
586
65
        (*node).__set_float_literal(float_literal);
587
65
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
65
    } else if constexpr (T == TYPE_DOUBLE) {
589
2
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
2
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
2
        TFloatLiteral float_literal;
592
2
        float_literal.__set_value(*origin_value);
593
2
        (*node).__set_float_literal(float_literal);
594
2
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
1.39k
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
1.39k
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
1.39k
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
1.39k
        TStringLiteral string_literal;
599
1.39k
        string_literal.__set_value(*origin_value);
600
1.39k
        (*node).__set_string_literal(string_literal);
601
1.39k
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
1.39k
    } else if constexpr (T == TYPE_IPV4) {
603
4
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
4
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
4
        TIPv4Literal literal;
606
4
        literal.__set_value(*origin_value);
607
4
        (*node).__set_ipv4_literal(literal);
608
4
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
4
    } else if constexpr (T == TYPE_IPV6) {
610
0
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
0
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
0
        TIPv6Literal literal;
613
0
        literal.__set_value(CastToString::from_ip(*origin_value));
614
0
        (*node).__set_ipv6_literal(literal);
615
0
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
1
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
1
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
1
        TTimeV2Literal timev2_literal;
621
1
        timev2_literal.__set_value(*origin_value);
622
1
        (*node).__set_timev2_literal(timev2_literal);
623
1
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
1
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
1
    } else if constexpr (T == TYPE_VARBINARY) {
626
0
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
0
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
0
        TVarBinaryLiteral varbinary_literal;
629
0
        varbinary_literal.__set_value(*origin_value);
630
0
        (*node).__set_varbinary_literal(varbinary_literal);
631
0
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
32.2k
    return Status::OK();
636
32.2k
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE2EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
89
                                 int scale = 0) {
457
89
    if constexpr (T == TYPE_BOOLEAN) {
458
89
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
89
        TBoolLiteral boolLiteral;
460
89
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
89
        boolLiteral.__set_value(*origin_value);
462
89
        (*node).__set_bool_literal(boolLiteral);
463
89
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
89
    return Status::OK();
636
89
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE3EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
535
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
535
    } else if constexpr (T == TYPE_TINYINT) {
465
535
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
535
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
535
        TIntLiteral intLiteral;
468
535
        intLiteral.__set_value(*origin_value);
469
535
        (*node).__set_int_literal(intLiteral);
470
535
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
535
    return Status::OK();
636
535
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE4EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
285
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
285
    } else if constexpr (T == TYPE_SMALLINT) {
472
285
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
285
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
285
        TIntLiteral intLiteral;
475
285
        intLiteral.__set_value(*origin_value);
476
285
        (*node).__set_int_literal(intLiteral);
477
285
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
285
    return Status::OK();
636
285
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE5EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
7.78k
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
7.78k
    } else if constexpr (T == TYPE_INT) {
479
7.78k
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
7.78k
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
7.78k
        TIntLiteral intLiteral;
482
7.78k
        intLiteral.__set_value(*origin_value);
483
7.78k
        (*node).__set_int_literal(intLiteral);
484
7.78k
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
7.78k
    return Status::OK();
636
7.78k
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE6EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
18.6k
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
18.6k
    } else if constexpr (T == TYPE_BIGINT) {
486
18.6k
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
18.6k
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
18.6k
        TIntLiteral intLiteral;
489
18.6k
        intLiteral.__set_value(*origin_value);
490
18.6k
        (*node).__set_int_literal(intLiteral);
491
18.6k
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
18.6k
    return Status::OK();
636
18.6k
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE7EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
38
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
38
    } else if constexpr (T == TYPE_LARGEINT) {
493
38
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
38
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
38
        TLargeIntLiteral large_int_literal;
496
38
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
38
        (*node).__set_large_int_literal(large_int_literal);
498
38
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
38
    return Status::OK();
636
38
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE8EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
65
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
65
    } else if constexpr (T == TYPE_FLOAT) {
582
65
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
65
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
65
        TFloatLiteral float_literal;
585
65
        float_literal.__set_value(*origin_value);
586
65
        (*node).__set_float_literal(float_literal);
587
65
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
65
    return Status::OK();
636
65
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE9EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
2
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
2
    } else if constexpr (T == TYPE_DOUBLE) {
589
2
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
2
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
2
        TFloatLiteral float_literal;
592
2
        float_literal.__set_value(*origin_value);
593
2
        (*node).__set_float_literal(float_literal);
594
2
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
2
    return Status::OK();
636
2
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE25EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
344
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
344
    } else if constexpr (T == TYPE_DATEV2) {
513
344
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
344
        TDateLiteral date_literal;
515
344
        char convert_buffer[30];
516
344
        origin_value->to_string(convert_buffer);
517
344
        date_literal.__set_value(convert_buffer);
518
344
        (*node).__set_date_literal(date_literal);
519
344
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
344
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
344
    return Status::OK();
636
344
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE26EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
948
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
948
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
948
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
948
        TDateLiteral date_literal;
524
948
        char convert_buffer[30];
525
948
        origin_value->to_string(convert_buffer, scale);
526
948
        date_literal.__set_value(convert_buffer);
527
948
        (*node).__set_date_literal(date_literal);
528
948
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
948
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
948
    return Status::OK();
636
948
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE11EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
1
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
1
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
1
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
1
        TDateLiteral date_literal;
502
1
        char convert_buffer[30];
503
1
        origin_value->to_string(convert_buffer);
504
1
        date_literal.__set_value(convert_buffer);
505
1
        (*node).__set_date_literal(date_literal);
506
1
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
1
        if (origin_value->type() == TimeType::TIME_DATE) {
508
1
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
1
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
0
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
0
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
1
    return Status::OK();
636
1
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE12EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
19
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
19
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
19
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
19
        TDateLiteral date_literal;
502
19
        char convert_buffer[30];
503
19
        origin_value->to_string(convert_buffer);
504
19
        date_literal.__set_value(convert_buffer);
505
19
        (*node).__set_date_literal(date_literal);
506
19
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
19
        if (origin_value->type() == TimeType::TIME_DATE) {
508
0
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
19
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
19
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
19
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
19
    return Status::OK();
636
19
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE20EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
5
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
5
    } else if constexpr (T == TYPE_DECIMALV2) {
540
5
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
5
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
5
        TDecimalLiteral decimal_literal;
543
5
        decimal_literal.__set_value(origin_value->to_string());
544
5
        (*node).__set_decimal_literal(decimal_literal);
545
5
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
5
    return Status::OK();
636
5
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE28EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
16
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
16
    } else if constexpr (T == TYPE_DECIMAL32) {
547
16
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
16
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
16
        TDecimalLiteral decimal_literal;
550
16
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
16
        (*node).__set_decimal_literal(decimal_literal);
552
16
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
16
    return Status::OK();
636
16
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE29EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
1.94k
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
1.94k
    } else if constexpr (T == TYPE_DECIMAL64) {
554
1.94k
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
1.94k
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
1.94k
        TDecimalLiteral decimal_literal;
557
1.94k
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
1.94k
        (*node).__set_decimal_literal(decimal_literal);
559
1.94k
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
1.94k
    return Status::OK();
636
1.94k
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE30EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
94
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
94
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
94
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
94
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
94
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
94
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
94
        (*node).__set_decimal_literal(decimal_literal);
573
94
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
94
    return Status::OK();
636
94
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE35EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
65
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
65
    } else if constexpr (T == TYPE_DECIMAL256) {
575
65
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
65
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
65
        TDecimalLiteral decimal_literal;
578
65
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
65
        (*node).__set_decimal_literal(decimal_literal);
580
65
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
65
    return Status::OK();
636
65
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE15EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
53
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
53
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
53
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
53
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
53
        TStringLiteral string_literal;
599
53
        string_literal.__set_value(*origin_value);
600
53
        (*node).__set_string_literal(string_literal);
601
53
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
53
    return Status::OK();
636
53
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE10EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
521
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
521
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
521
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
521
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
521
        TStringLiteral string_literal;
599
521
        string_literal.__set_value(*origin_value);
600
521
        (*node).__set_string_literal(string_literal);
601
521
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
521
    return Status::OK();
636
521
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE23EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
822
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
822
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
822
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
822
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
822
        TStringLiteral string_literal;
599
822
        string_literal.__set_value(*origin_value);
600
822
        (*node).__set_string_literal(string_literal);
601
822
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
822
    return Status::OK();
636
822
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE36EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
4
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
4
    } else if constexpr (T == TYPE_IPV4) {
603
4
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
4
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
4
        TIPv4Literal literal;
606
4
        literal.__set_value(*origin_value);
607
4
        (*node).__set_ipv4_literal(literal);
608
4
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
4
    return Status::OK();
636
4
}
Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE37EEENS_6StatusEPKvPNS_9TExprNodeEii
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE27EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
1
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
        TDateLiteral date_literal;
533
        auto tz = cctz::utc_time_zone();
534
        auto tz_str = origin_value->to_string(tz, scale);
535
        date_literal.__set_value(tz_str);
536
        (*node).__set_date_literal(date_literal);
537
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
1
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
1
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
1
        TTimeV2Literal timev2_literal;
621
1
        timev2_literal.__set_value(*origin_value);
622
1
        (*node).__set_timev2_literal(timev2_literal);
623
1
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
1
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
1
    return Status::OK();
636
1
}
_ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE42EEENS_6StatusEPKvPNS_9TExprNodeEii
Line
Count
Source
456
6
                                 int scale = 0) {
457
    if constexpr (T == TYPE_BOOLEAN) {
458
        const auto* origin_value = reinterpret_cast<const bool*>(data);
459
        TBoolLiteral boolLiteral;
460
        (*node).__set_node_type(TExprNodeType::BOOL_LITERAL);
461
        boolLiteral.__set_value(*origin_value);
462
        (*node).__set_bool_literal(boolLiteral);
463
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BOOLEAN));
464
    } else if constexpr (T == TYPE_TINYINT) {
465
        const auto* origin_value = reinterpret_cast<const int8_t*>(data);
466
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
467
        TIntLiteral intLiteral;
468
        intLiteral.__set_value(*origin_value);
469
        (*node).__set_int_literal(intLiteral);
470
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TINYINT));
471
    } else if constexpr (T == TYPE_SMALLINT) {
472
        const auto* origin_value = reinterpret_cast<const int16_t*>(data);
473
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
474
        TIntLiteral intLiteral;
475
        intLiteral.__set_value(*origin_value);
476
        (*node).__set_int_literal(intLiteral);
477
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_SMALLINT));
478
    } else if constexpr (T == TYPE_INT) {
479
        const auto* origin_value = reinterpret_cast<const int32_t*>(data);
480
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
481
        TIntLiteral intLiteral;
482
        intLiteral.__set_value(*origin_value);
483
        (*node).__set_int_literal(intLiteral);
484
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_INT));
485
    } else if constexpr (T == TYPE_BIGINT) {
486
        const auto* origin_value = reinterpret_cast<const int64_t*>(data);
487
        (*node).__set_node_type(TExprNodeType::INT_LITERAL);
488
        TIntLiteral intLiteral;
489
        intLiteral.__set_value(*origin_value);
490
        (*node).__set_int_literal(intLiteral);
491
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_BIGINT));
492
    } else if constexpr (T == TYPE_LARGEINT) {
493
        const auto* origin_value = reinterpret_cast<const int128_t*>(data);
494
        (*node).__set_node_type(TExprNodeType::LARGE_INT_LITERAL);
495
        TLargeIntLiteral large_int_literal;
496
        large_int_literal.__set_value(LargeIntValue::to_string(*origin_value));
497
        (*node).__set_large_int_literal(large_int_literal);
498
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_LARGEINT));
499
    } else if constexpr ((T == TYPE_DATE) || (T == TYPE_DATETIME)) {
500
        const auto* origin_value = reinterpret_cast<const VecDateTimeValue*>(data);
501
        TDateLiteral date_literal;
502
        char convert_buffer[30];
503
        origin_value->to_string(convert_buffer);
504
        date_literal.__set_value(convert_buffer);
505
        (*node).__set_date_literal(date_literal);
506
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
507
        if (origin_value->type() == TimeType::TIME_DATE) {
508
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATE));
509
        } else if (origin_value->type() == TimeType::TIME_DATETIME) {
510
            (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIME));
511
        }
512
    } else if constexpr (T == TYPE_DATEV2) {
513
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateV2ValueType>*>(data);
514
        TDateLiteral date_literal;
515
        char convert_buffer[30];
516
        origin_value->to_string(convert_buffer);
517
        date_literal.__set_value(convert_buffer);
518
        (*node).__set_date_literal(date_literal);
519
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
520
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATEV2));
521
    } else if constexpr (T == TYPE_DATETIMEV2) {
522
        const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
523
        TDateLiteral date_literal;
524
        char convert_buffer[30];
525
        origin_value->to_string(convert_buffer, scale);
526
        date_literal.__set_value(convert_buffer);
527
        (*node).__set_date_literal(date_literal);
528
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
529
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
530
6
    } else if constexpr (T == TYPE_TIMESTAMPTZ) {
531
6
        const auto* origin_value = reinterpret_cast<const TimestampTzValue*>(data);
532
6
        TDateLiteral date_literal;
533
6
        auto tz = cctz::utc_time_zone();
534
6
        auto tz_str = origin_value->to_string(tz, scale);
535
6
        date_literal.__set_value(tz_str);
536
6
        (*node).__set_date_literal(date_literal);
537
6
        (*node).__set_node_type(TExprNodeType::DATE_LITERAL);
538
6
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMESTAMPTZ, precision, scale));
539
    } else if constexpr (T == TYPE_DECIMALV2) {
540
        const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
541
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
542
        TDecimalLiteral decimal_literal;
543
        decimal_literal.__set_value(origin_value->to_string());
544
        (*node).__set_decimal_literal(decimal_literal);
545
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMALV2, precision, scale));
546
    } else if constexpr (T == TYPE_DECIMAL32) {
547
        const auto* origin_value = reinterpret_cast<const Decimal<int32_t>*>(data);
548
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
549
        TDecimalLiteral decimal_literal;
550
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
551
        (*node).__set_decimal_literal(decimal_literal);
552
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL32, precision, scale));
553
    } else if constexpr (T == TYPE_DECIMAL64) {
554
        const auto* origin_value = reinterpret_cast<const Decimal<int64_t>*>(data);
555
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
556
        TDecimalLiteral decimal_literal;
557
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
558
        (*node).__set_decimal_literal(decimal_literal);
559
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL64, precision, scale));
560
    } else if constexpr (T == TYPE_DECIMAL128I) {
561
        const auto* origin_value = reinterpret_cast<const Decimal<int128_t>*>(data);
562
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
563
        TDecimalLiteral decimal_literal;
564
        // e.g. For a decimal(26,6) column, the initial value of the _min of the MinMax RF
565
        // on the RF producer side is an int128 value with 38 digits of 9, and this is the
566
        // final min value of the MinMax RF if the fragment instance has no data.
567
        // Need to truncate the value to the right precision and scale here, to avoid
568
        // error when casting string back to decimal later.
569
        // TODO: this is a temporary solution, the best solution is to produce the
570
        // right min max value at the producer side.
571
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
572
        (*node).__set_decimal_literal(decimal_literal);
573
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, precision, scale));
574
    } else if constexpr (T == TYPE_DECIMAL256) {
575
        const auto* origin_value = reinterpret_cast<const Decimal<wide::Int256>*>(data);
576
        (*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
577
        TDecimalLiteral decimal_literal;
578
        decimal_literal.__set_value(origin_value->to_string(precision, scale));
579
        (*node).__set_decimal_literal(decimal_literal);
580
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL256, precision, scale));
581
    } else if constexpr (T == TYPE_FLOAT) {
582
        const auto* origin_value = reinterpret_cast<const float*>(data);
583
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
584
        TFloatLiteral float_literal;
585
        float_literal.__set_value(*origin_value);
586
        (*node).__set_float_literal(float_literal);
587
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_FLOAT));
588
    } else if constexpr (T == TYPE_DOUBLE) {
589
        const auto* origin_value = reinterpret_cast<const double*>(data);
590
        (*node).__set_node_type(TExprNodeType::FLOAT_LITERAL);
591
        TFloatLiteral float_literal;
592
        float_literal.__set_value(*origin_value);
593
        (*node).__set_float_literal(float_literal);
594
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DOUBLE));
595
    } else if constexpr ((T == TYPE_STRING) || (T == TYPE_CHAR) || (T == TYPE_VARCHAR)) {
596
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
597
        (*node).__set_node_type(TExprNodeType::STRING_LITERAL);
598
        TStringLiteral string_literal;
599
        string_literal.__set_value(*origin_value);
600
        (*node).__set_string_literal(string_literal);
601
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_STRING));
602
    } else if constexpr (T == TYPE_IPV4) {
603
        const auto* origin_value = reinterpret_cast<const IPv4*>(data);
604
        (*node).__set_node_type(TExprNodeType::IPV4_LITERAL);
605
        TIPv4Literal literal;
606
        literal.__set_value(*origin_value);
607
        (*node).__set_ipv4_literal(literal);
608
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV4));
609
    } else if constexpr (T == TYPE_IPV6) {
610
        const auto* origin_value = reinterpret_cast<const IPv6*>(data);
611
        (*node).__set_node_type(TExprNodeType::IPV6_LITERAL);
612
        TIPv6Literal literal;
613
        literal.__set_value(CastToString::from_ip(*origin_value));
614
        (*node).__set_ipv6_literal(literal);
615
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_IPV6));
616
    } else if constexpr (T == TYPE_TIMEV2) {
617
        // the code use for runtime filter but we dont support timev2 as predicate now
618
        // so this part not used
619
        const auto* origin_value = reinterpret_cast<const double*>(data);
620
        TTimeV2Literal timev2_literal;
621
        timev2_literal.__set_value(*origin_value);
622
        (*node).__set_timev2_literal(timev2_literal);
623
        (*node).__set_node_type(TExprNodeType::TIMEV2_LITERAL);
624
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_TIMEV2, precision, scale));
625
    } else if constexpr (T == TYPE_VARBINARY) {
626
        const auto* origin_value = reinterpret_cast<const std::string*>(data);
627
        (*node).__set_node_type(TExprNodeType::VARBINARY_LITERAL);
628
        TVarBinaryLiteral varbinary_literal;
629
        varbinary_literal.__set_value(*origin_value);
630
        (*node).__set_varbinary_literal(varbinary_literal);
631
        (*node).__set_type(create_type_desc(PrimitiveType::TYPE_VARBINARY));
632
    } else {
633
        return Status::InvalidArgument("Invalid argument type!");
634
    }
635
6
    return Status::OK();
636
6
}
Unexecuted instantiation: _ZN5doris25create_texpr_literal_nodeILNS_13PrimitiveTypeE41EEENS_6StatusEPKvPNS_9TExprNodeEii
637
// NOLINTEND(readability-function-size)
638
639
TExprNode create_texpr_node_from(const void* data, const PrimitiveType& type, int precision = 0,
640
                                 int scale = 0);
641
642
TExprNode create_texpr_node_from(const Field& field, const PrimitiveType& type, int precision,
643
                                 int scale);
644
645
} // namespace doris