Coverage Report

Created: 2026-07-27 17:15

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