Coverage Report

Created: 2025-06-18 22:01

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