Coverage Report

Created: 2025-10-14 17:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/vec/functions/function.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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/IFunction.h
19
// and modified by Doris
20
21
#pragma once
22
23
#include <fmt/format.h>
24
#include <glog/logging.h>
25
26
#include <cstddef>
27
#include <memory>
28
#include <string>
29
#include <utility>
30
31
#include "common/exception.h"
32
#include "common/logging.h"
33
#include "common/status.h"
34
#include "olap/rowset/segment_v2/inverted_index_iterator.h" // IWYU pragma: keep
35
#include "udf/udf.h"
36
#include "vec/core/block.h"
37
#include "vec/core/column_numbers.h"
38
#include "vec/core/column_with_type_and_name.h"
39
#include "vec/core/columns_with_type_and_name.h"
40
#include "vec/core/types.h"
41
#include "vec/data_types/data_type.h"
42
#include "vec/data_types/data_type_array.h"
43
#include "vec/data_types/data_type_map.h"
44
#include "vec/data_types/data_type_nullable.h"
45
#include "vec/data_types/data_type_struct.h"
46
47
namespace doris::vectorized {
48
49
struct FunctionAttr {
50
    bool enable_decimal256 {false};
51
    bool new_version_unix_timestamp {false};
52
};
53
54
#define RETURN_REAL_TYPE_FOR_DATEV2_FUNCTION(TYPE)                                             \
55
31
    bool is_nullable = false;                                                                  \
56
31
    bool is_datev2 = false;                                                                    \
57
53
    for (auto it : arguments) {                                                                \
58
53
        is_nullable = is_nullable || it.type->is_nullable();                                   \
59
53
        is_datev2 = is_datev2 || it.type->get_primitive_type() == TYPE_DATEV2 ||               \
60
53
                    it.type->get_primitive_type() == TYPE_DATETIMEV2;                          \
61
53
    }                                                                                          \
62
31
    return is_nullable || !is_datev2                                                           \
63
31
                   ? make_nullable(                                                            \
64
26
                             std::make_shared<typename PrimitiveTypeTraits<TYPE>::DataType>()) \
65
31
                   : std::make_shared<typename PrimitiveTypeTraits<TYPE>::DataType>();
66
67
#define SET_NULLMAP_IF_FALSE(EXPR) \
68
    if (!EXPR) [[unlikely]] {      \
69
        null_map[i] = true;        \
70
    }
71
72
class Field;
73
class VExpr;
74
75
// Only use dispose the variadic argument
76
template <typename T>
77
auto has_variadic_argument_types(T&& arg) -> decltype(T::get_variadic_argument_types()) {};
78
void has_variadic_argument_types(...);
79
80
template <typename T>
81
concept HasGetVariadicArgumentTypesImpl = requires(T t) {
82
    { t.get_variadic_argument_types_impl() } -> std::same_as<DataTypes>;
83
};
84
85
bool have_null_column(const Block& block, const ColumnNumbers& args);
86
bool have_null_column(const ColumnsWithTypeAndName& args);
87
88
/// The simplest executable object.
89
/// Motivation:
90
///  * Prepare something heavy once before main execution loop instead of doing it for each block.
91
///  * Provide const interface for IFunctionBase (later).
92
class IPreparedFunction {
93
public:
94
100k
    virtual ~IPreparedFunction() = default;
95
96
    /// Get the main function name.
97
    virtual String get_name() const = 0;
98
99
    virtual Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
100
                           uint32_t result, size_t input_rows_count, bool dry_run) const = 0;
101
};
102
103
using PreparedFunctionPtr = std::shared_ptr<IPreparedFunction>;
104
105
class PreparedFunctionImpl : public IPreparedFunction {
106
public:
107
    Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
108
                   uint32_t result, size_t input_rows_count, bool dry_run = false) const final;
109
110
    /** If the function have non-zero number of arguments,
111
      *  and if all arguments are constant, that we could automatically provide default implementation:
112
      *  arguments are converted to ordinary columns with single value which is not const, then function is executed as usual,
113
      *  and then the result is converted to constant column.
114
      */
115
106k
    virtual bool use_default_implementation_for_constants() const { return true; }
116
117
    /** If use_default_implementation_for_nulls() is true, after execute the function,
118
      * whether need to replace the nested data of null data to the default value.
119
      * E.g. for binary arithmetic exprs, need return true to avoid false overflow.
120
      */
121
0
    virtual bool need_replace_null_data_to_default() const { return false; }
122
123
protected:
124
    virtual Status execute_impl_dry_run(FunctionContext* context, Block& block,
125
                                        const ColumnNumbers& arguments, uint32_t result,
126
0
                                        size_t input_rows_count) const {
127
0
        return execute_impl(context, block, arguments, result, input_rows_count);
128
0
    }
129
130
    virtual Status execute_impl(FunctionContext* context, Block& block,
131
                                const ColumnNumbers& arguments, uint32_t result,
132
                                size_t input_rows_count) const = 0;
133
134
    /** Default implementation in presence of Nullable arguments or NULL constants as arguments is the following:
135
      *  if some of arguments are NULL constants then return NULL constant,
136
      *  if some of arguments are Nullable, then execute function as usual for block,
137
      *   where Nullable columns are substituted with nested columns (they have arbitrary values in rows corresponding to NULL value)
138
      *   and wrap result in Nullable column where NULLs are in all rows where any of arguments are NULL.
139
      */
140
0
    virtual bool use_default_implementation_for_nulls() const { return true; }
141
142
0
    virtual bool skip_return_type_check() const { return false; }
143
144
    /** Some arguments could remain constant during this implementation.
145
      * Every argument required const must write here and no checks elsewhere.
146
      */
147
0
    virtual ColumnNumbers get_arguments_that_are_always_constant() const { return {}; }
148
149
private:
150
    Status default_implementation_for_nulls(FunctionContext* context, Block& block,
151
                                            const ColumnNumbers& args, uint32_t result,
152
                                            size_t input_rows_count, bool dry_run,
153
                                            bool* executed) const;
154
    Status default_implementation_for_constant_arguments(FunctionContext* context, Block& block,
155
                                                         const ColumnNumbers& args, uint32_t result,
156
                                                         size_t input_rows_count, bool dry_run,
157
                                                         bool* executed) const;
158
    Status execute_without_low_cardinality_columns(FunctionContext* context, Block& block,
159
                                                   const ColumnNumbers& arguments, uint32_t result,
160
                                                   size_t input_rows_count, bool dry_run) const;
161
    Status _execute_skipped_constant_deal(FunctionContext* context, Block& block,
162
                                          const ColumnNumbers& args, uint32_t result,
163
                                          size_t input_rows_count, bool dry_run) const;
164
};
165
166
/// Function with known arguments and return type.
167
class IFunctionBase {
168
public:
169
113k
    virtual ~IFunctionBase() = default;
170
171
    /// Get the main function name.
172
    virtual String get_name() const = 0;
173
174
    virtual const DataTypes& get_argument_types() const = 0;
175
    virtual const DataTypePtr& get_return_type() const = 0;
176
177
    /// Do preparations and return executable.
178
    /// sample_block should contain data types of arguments and values of constants, if relevant.
179
    virtual PreparedFunctionPtr prepare(FunctionContext* context, const Block& sample_block,
180
                                        const ColumnNumbers& arguments, uint32_t result) const = 0;
181
182
    /// Override this when function need to store state in the `FunctionContext`, or do some
183
    /// preparation work according to information from `FunctionContext`.
184
74.4k
    virtual Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
185
74.4k
        return Status::OK();
186
74.4k
    }
187
188
    Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
189
98.1k
                   uint32_t result, size_t input_rows_count, bool dry_run = false) const {
190
98.1k
        try {
191
98.1k
            return prepare(context, block, arguments, result)
192
98.1k
                    ->execute(context, block, arguments, result, input_rows_count, dry_run);
193
98.1k
        } catch (const Exception& e) {
194
1
            return e.to_status();
195
1
        }
196
98.1k
    }
197
198
    virtual Status evaluate_inverted_index(
199
            const ColumnsWithTypeAndName& arguments,
200
            const std::vector<vectorized::IndexFieldNameAndTypePair>& data_type_with_names,
201
            std::vector<segment_v2::IndexIterator*> iterators, uint32_t num_rows,
202
0
            segment_v2::InvertedIndexResultBitmap& bitmap_result) const {
203
0
        return Status::OK();
204
0
    }
205
206
    /// Do cleaning work when function is finished, i.e., release state variables in the
207
    /// `FunctionContext` which are registered in `prepare` phase.
208
47.5k
    virtual Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
209
47.5k
        return Status::OK();
210
47.5k
    }
211
212
    virtual bool is_use_default_implementation_for_constants() const = 0;
213
214
0
    virtual bool is_udf_function() const { return false; }
215
216
0
    virtual bool can_push_down_to_index() const { return false; }
217
218
0
    virtual bool is_blockable() const { return false; }
219
};
220
221
using FunctionBasePtr = std::shared_ptr<IFunctionBase>;
222
223
/// Creates IFunctionBase from argument types list.
224
class IFunctionBuilder {
225
public:
226
115k
    virtual ~IFunctionBuilder() = default;
227
228
    /// Get the main function name.
229
    virtual String get_name() const = 0;
230
231
    /// Override and return true if function could take different number of arguments.
232
    ///TODO: this function is not actually used now. but in check_number_of_arguments we still need it because for many
233
    /// functions we didn't set the correct number of arguments.
234
    virtual bool is_variadic() const = 0;
235
236
    /// For non-variadic functions, return number of arguments; otherwise return zero (that should be ignored).
237
    virtual size_t get_number_of_arguments() const = 0;
238
239
    /// Throw if number of arguments is incorrect. Default implementation will check only in non-variadic case.
240
    virtual void check_number_of_arguments(size_t number_of_arguments) const = 0;
241
242
    /// Check arguments and return IFunctionBase.
243
    virtual FunctionBasePtr build(const ColumnsWithTypeAndName& arguments,
244
                                  const DataTypePtr& return_type) const = 0;
245
246
    /// For higher-order functions (functions, that have lambda expression as at least one argument).
247
    /// You pass data types with empty DataTypeFunction for lambda arguments.
248
    /// This function will replace it with DataTypeFunction containing actual types.
249
    virtual DataTypes get_variadic_argument_types() const = 0;
250
251
    /// Returns indexes of arguments, that must be ColumnConst
252
    virtual ColumnNumbers get_arguments_that_are_always_constant() const = 0;
253
};
254
255
using FunctionBuilderPtr = std::shared_ptr<IFunctionBuilder>;
256
257
3
inline std::string get_types_string(const ColumnsWithTypeAndName& arguments) {
258
3
    std::string types;
259
3
    for (const auto& argument : arguments) {
260
2
        if (!types.empty()) {
261
1
            types += ", ";
262
1
        }
263
2
        types += argument.type->get_name();
264
2
    }
265
3
    return types;
266
3
}
267
268
/// used in function_factory. when we register a function, save a builder. to get a function, to get a builder.
269
/// will use DefaultFunctionBuilder as the default builder in function's registration if we didn't explicitly specify.
270
class FunctionBuilderImpl : public IFunctionBuilder {
271
public:
272
    FunctionBasePtr build(const ColumnsWithTypeAndName& arguments,
273
98.6k
                          const DataTypePtr& return_type) const final {
274
98.6k
        if (skip_return_type_check()) {
275
85.9k
            return build_impl(arguments, return_type);
276
85.9k
        }
277
12.6k
        const DataTypePtr& func_return_type = get_return_type(arguments);
278
12.6k
        if (func_return_type == nullptr) {
279
1
            throw doris::Exception(
280
1
                    ErrorCode::INTERNAL_ERROR,
281
1
                    "function return type check failed, function_name={}, "
282
1
                    "expect_return_type={}, real_return_type is nullptr, input_arguments={}",
283
1
                    get_name(), return_type->get_name(), get_types_string(arguments));
284
1
        }
285
286
        // check return types equal.
287
12.6k
        if (!(return_type->equals(*func_return_type) ||
288
              // For null constant argument, `get_return_type` would return
289
              // Nullable<DataTypeNothing> when `use_default_implementation_for_nulls` is true.
290
12.6k
              (return_type->is_nullable() && func_return_type->is_nullable() &&
291
9
               ((DataTypeNullable*)func_return_type.get())
292
4
                               ->get_nested_type()
293
4
                               ->get_primitive_type() == INVALID_TYPE) ||
294
12.6k
              is_date_or_datetime_or_decimal(return_type, func_return_type) ||
295
12.6k
              is_nested_type_date_or_datetime_or_decimal(return_type, func_return_type))) {
296
2
            throw doris::Exception(
297
2
                    ErrorCode::INTERNAL_ERROR,
298
2
                    "function return type check failed, function_name={}, "
299
2
                    "fe plan return type={},  be real return type={}, input_arguments={}",
300
2
                    get_name(), return_type->get_name(), func_return_type->get_name(),
301
2
                    get_types_string(arguments));
302
2
        }
303
12.6k
        return build_impl(arguments, return_type);
304
12.6k
    }
305
306
8.92k
    bool is_variadic() const override { return false; }
307
308
    // Default implementation. Will check only in non-variadic case.
309
    void check_number_of_arguments(size_t number_of_arguments) const override;
310
    // the return type should be same with what FE plans.
311
    // it returns: `get_return_type_impl` if `use_default_implementation_for_nulls` = false
312
    //  `get_return_type_impl` warpped in NULL if `use_default_implementation_for_nulls` = true and input has NULL
313
    DataTypePtr get_return_type(const ColumnsWithTypeAndName& arguments) const;
314
315
1.07k
    DataTypes get_variadic_argument_types() const override {
316
1.07k
        return get_variadic_argument_types_impl();
317
1.07k
    }
318
319
0
    ColumnNumbers get_arguments_that_are_always_constant() const override { return {}; }
320
321
protected:
322
    // Get the result type by argument type. If the function does not apply to these arguments, throw an exception.
323
    // the get_return_type_impl and its overrides should only return the nested type if `use_default_implementation_for_nulls` is true.
324
    // whether to wrap in nullable type will be automatically decided.
325
12.4k
    virtual DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const {
326
12.4k
        DataTypes data_types(arguments.size());
327
45.8k
        for (size_t i = 0; i < arguments.size(); ++i) {
328
33.4k
            data_types[i] = arguments[i].type;
329
33.4k
        }
330
12.4k
        return get_return_type_impl(data_types);
331
12.4k
    }
332
333
0
    virtual DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const {
334
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
335
0
                               "get_return_type is not implemented for {}", get_name());
336
0
        return nullptr;
337
0
    }
338
339
    /** If use_default_implementation_for_nulls() is true, than change arguments for get_return_type() and build_impl():
340
      *  if some of arguments are Nullable(Nothing) then don't call get_return_type(), call build_impl() with return_type = Nullable(Nothing),
341
      *  if some of arguments are Nullable, then:
342
      *   - Nullable types are substituted with nested types for get_return_type() function
343
      *   - WRAP get_return_type() RESULT IN NULLABLE type and pass to build_impl
344
      *
345
      * Otherwise build returns build_impl(arguments, get_return_type(arguments));
346
      */
347
0
    virtual bool use_default_implementation_for_nulls() const { return true; }
348
349
0
    virtual bool skip_return_type_check() const { return false; }
350
351
0
    virtual bool need_replace_null_data_to_default() const { return false; }
352
353
    /// return a real function object to execute. called in build(...).
354
    virtual FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments,
355
                                       const DataTypePtr& return_type) const = 0;
356
357
354
    virtual DataTypes get_variadic_argument_types_impl() const { return {}; }
358
359
private:
360
    bool is_date_or_datetime_or_decimal(const DataTypePtr& return_type,
361
                                        const DataTypePtr& func_return_type) const;
362
    bool is_nested_type_date_or_datetime_or_decimal(const DataTypePtr& return_type,
363
                                                    const DataTypePtr& func_return_type) const;
364
};
365
366
/// Previous function interface.
367
class IFunction : public std::enable_shared_from_this<IFunction>,
368
                  public FunctionBuilderImpl,
369
                  public IFunctionBase,
370
                  public PreparedFunctionImpl {
371
public:
372
    String get_name() const override = 0;
373
374
    /// Notice: We should not change the column in the block, because the column may be shared by multiple expressions or exec nodes.
375
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
376
                        uint32_t result, size_t input_rows_count) const override = 0;
377
378
    /// Override this functions to change default implementation behavior. See details in IMyFunction.
379
30.8k
    bool use_default_implementation_for_nulls() const override { return true; }
380
381
12.6k
    bool skip_return_type_check() const override { return false; }
382
383
7.66k
    bool need_replace_null_data_to_default() const override { return false; }
384
385
    /// all constancy check should use this function to do automatically
386
20.4k
    ColumnNumbers get_arguments_that_are_always_constant() const override { return {}; }
387
388
43
    bool is_use_default_implementation_for_constants() const override {
389
43
        return use_default_implementation_for_constants();
390
43
    }
391
392
    using PreparedFunctionImpl::execute;
393
    using PreparedFunctionImpl::execute_impl_dry_run;
394
    using FunctionBuilderImpl::get_return_type_impl;
395
    using FunctionBuilderImpl::get_variadic_argument_types_impl;
396
    using FunctionBuilderImpl::get_return_type;
397
398
    [[noreturn]] PreparedFunctionPtr prepare(FunctionContext* context,
399
                                             const Block& /*sample_block*/,
400
                                             const ColumnNumbers& /*arguments*/,
401
0
                                             uint32_t /*result*/) const final {
402
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
403
0
                               "prepare is not implemented for IFunction {}", get_name());
404
0
        __builtin_unreachable();
405
0
    }
406
407
22.9k
    Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) override {
408
22.9k
        return Status::OK();
409
22.9k
    }
410
411
0
    [[noreturn]] const DataTypes& get_argument_types() const final {
412
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
413
0
                               "get_argument_types is not implemented for IFunction {}",
414
0
                               get_name());
415
0
        __builtin_unreachable();
416
0
    }
417
418
0
    [[noreturn]] const DataTypePtr& get_return_type() const final {
419
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
420
0
                               "get_return_type is not implemented for IFunction {}", get_name());
421
0
        __builtin_unreachable();
422
0
    }
423
424
protected:
425
    FunctionBasePtr build_impl(const ColumnsWithTypeAndName& /*arguments*/,
426
0
                               const DataTypePtr& /*return_type*/) const final {
427
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
428
0
                               "build_impl is not implemented for IFunction {}", get_name());
429
0
        __builtin_unreachable();
430
0
        return {};
431
0
    }
432
};
433
434
/*
435
 * when we register a function which didn't specify its base(i.e. inherited from IFunction), actually we use this as a wrapper.
436
 * it saves real implementation as `function`. 
437
*/
438
class DefaultFunction final : public IFunctionBase {
439
public:
440
    DefaultFunction(std::shared_ptr<IFunction> function_, DataTypes arguments_,
441
                    DataTypePtr return_type_)
442
12.6k
            : function(std::move(function_)),
443
12.6k
              arguments(std::move(arguments_)),
444
12.6k
              return_type(std::move(return_type_)) {}
445
446
0
    String get_name() const override { return function->get_name(); }
447
448
0
    const DataTypes& get_argument_types() const override { return arguments; }
449
1
    const DataTypePtr& get_return_type() const override { return return_type; }
450
451
    // return a default wrapper for IFunction.
452
    PreparedFunctionPtr prepare(FunctionContext* context, const Block& /*sample_block*/,
453
                                const ColumnNumbers& /*arguments*/,
454
12.6k
                                uint32_t /*result*/) const override {
455
12.6k
        return function;
456
12.6k
    }
457
458
24.7k
    Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) override {
459
24.7k
        return function->open(context, scope);
460
24.7k
    }
461
462
24.6k
    Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) override {
463
24.6k
        return function->close(context, scope);
464
24.6k
    }
465
466
    Status evaluate_inverted_index(
467
            const ColumnsWithTypeAndName& args,
468
            const std::vector<vectorized::IndexFieldNameAndTypePair>& data_type_with_names,
469
            std::vector<segment_v2::IndexIterator*> iterators, uint32_t num_rows,
470
0
            segment_v2::InvertedIndexResultBitmap& bitmap_result) const override {
471
0
        return function->evaluate_inverted_index(args, data_type_with_names, iterators, num_rows,
472
0
                                                 bitmap_result);
473
0
    }
474
475
43
    bool is_use_default_implementation_for_constants() const override {
476
43
        return function->is_use_default_implementation_for_constants();
477
43
    }
478
479
0
    bool can_push_down_to_index() const override { return function->can_push_down_to_index(); }
480
481
0
    bool is_blockable() const override { return function->is_blockable(); }
482
483
private:
484
    std::shared_ptr<IFunction> function;
485
    DataTypes arguments;
486
    DataTypePtr return_type;
487
};
488
489
class DefaultFunctionBuilder : public FunctionBuilderImpl {
490
public:
491
    explicit DefaultFunctionBuilder(std::shared_ptr<IFunction> function_)
492
14.7k
            : function(std::move(function_)) {}
493
494
12.6k
    void check_number_of_arguments(size_t number_of_arguments) const override {
495
12.6k
        function->check_number_of_arguments(number_of_arguments);
496
12.6k
    }
497
498
490
    String get_name() const override { return function->get_name(); }
499
1.04k
    bool is_variadic() const override { return function->is_variadic(); }
500
0
    size_t get_number_of_arguments() const override { return function->get_number_of_arguments(); }
501
502
0
    ColumnNumbers get_arguments_that_are_always_constant() const override {
503
0
        return function->get_arguments_that_are_always_constant();
504
0
    }
505
506
protected:
507
0
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
508
0
        return function->get_return_type_impl(arguments);
509
0
    }
510
12.6k
    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
511
12.6k
        return function->get_return_type_impl(arguments);
512
12.6k
    }
513
514
12.6k
    bool use_default_implementation_for_nulls() const override {
515
12.6k
        return function->use_default_implementation_for_nulls();
516
12.6k
    }
517
518
12.6k
    bool skip_return_type_check() const override { return function->skip_return_type_check(); }
519
520
0
    bool need_replace_null_data_to_default() const override {
521
0
        return function->need_replace_null_data_to_default();
522
0
    }
523
524
    FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments,
525
12.6k
                               const DataTypePtr& return_type) const override {
526
12.6k
        DataTypes data_types(arguments.size());
527
46.4k
        for (size_t i = 0; i < arguments.size(); ++i) {
528
33.8k
            data_types[i] = arguments[i].type;
529
33.8k
        }
530
12.6k
        return std::make_shared<DefaultFunction>(function, data_types, return_type);
531
12.6k
    }
532
533
1.07k
    DataTypes get_variadic_argument_types_impl() const override {
534
1.07k
        return function->get_variadic_argument_types_impl();
535
1.07k
    }
536
537
private:
538
    std::shared_ptr<IFunction> function;
539
};
540
541
using FunctionPtr = std::shared_ptr<IFunction>;
542
543
/** Return ColumnNullable of src, with null map as OR-ed null maps of args columns in blocks.
544
  * Or ColumnConst(ColumnNullable) if the result is always NULL or if the result is constant and always not NULL.
545
  */
546
ColumnPtr wrap_in_nullable(const ColumnPtr& src, const Block& block, const ColumnNumbers& args,
547
                           uint32_t result, size_t input_rows_count);
548
549
} // namespace doris::vectorized