Coverage Report

Created: 2026-07-28 21:24

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