Coverage Report

Created: 2026-03-15 15:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/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 "core/block/block.h"
35
#include "core/block/column_numbers.h"
36
#include "core/block/column_with_type_and_name.h"
37
#include "core/block/columns_with_type_and_name.h"
38
#include "core/data_type/data_type.h"
39
#include "core/data_type/data_type_array.h"
40
#include "core/data_type/data_type_map.h"
41
#include "core/data_type/data_type_nullable.h"
42
#include "core/data_type/data_type_struct.h"
43
#include "core/data_type/define_primitive_type.h"
44
#include "core/types.h"
45
#include "exprs/function_context.h"
46
#include "storage/index/inverted/inverted_index_iterator.h" // IWYU pragma: keep
47
#include "storage/index/inverted/inverted_index_parser.h"
48
49
namespace doris {
50
struct InvertedIndexAnalyzerCtx;
51
} // namespace doris
52
53
namespace doris {
54
55
struct FunctionAttr {
56
    bool new_version_unix_timestamp {false};
57
};
58
59
#define RETURN_REAL_TYPE_FOR_DATEV2_FUNCTION(TYPE)                                             \
60
1.20k
    bool is_nullable = false;                                                                  \
61
1.20k
    bool is_datev2 = false;                                                                    \
62
2.21k
    for (auto it : arguments) {                                                                \
63
2.21k
        is_nullable = is_nullable || it.type->is_nullable();                                   \
64
2.21k
        is_datev2 = is_datev2 || it.type->get_primitive_type() == TYPE_DATEV2 ||               \
65
2.21k
                    it.type->get_primitive_type() == TYPE_DATETIMEV2;                          \
66
2.21k
    }                                                                                          \
67
1.20k
    return is_nullable || !is_datev2                                                           \
68
1.20k
                   ? make_nullable(                                                            \
69
843
                             std::make_shared<typename PrimitiveTypeTraits<TYPE>::DataType>()) \
70
1.20k
                   : std::make_shared<typename PrimitiveTypeTraits<TYPE>::DataType>();
71
72
#define SET_NULLMAP_IF_FALSE(EXPR) \
73
    if (!EXPR) [[unlikely]] {      \
74
        null_map[i] = true;        \
75
    }
76
77
class Field;
78
class VExpr;
79
80
// Only use dispose the variadic argument
81
template <typename T>
82
auto has_variadic_argument_types(T&& arg) -> decltype(T::get_variadic_argument_types()) {};
83
void has_variadic_argument_types(...);
84
85
template <typename T>
86
concept HasGetVariadicArgumentTypesImpl = requires(T t) {
87
    { t.get_variadic_argument_types_impl() } -> std::same_as<DataTypes>;
88
};
89
90
bool have_null_column(const Block& block, const ColumnNumbers& args);
91
bool have_null_column(const ColumnsWithTypeAndName& args);
92
93
/// The simplest executable object.
94
/// Motivation:
95
///  * Prepare something heavy once before main execution loop instead of doing it for each block.
96
///  * Provide const interface for IFunctionBase (later).
97
class IPreparedFunction {
98
public:
99
907k
    virtual ~IPreparedFunction() = default;
100
101
    /// Get the main function name.
102
    virtual String get_name() const = 0;
103
104
    virtual Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
105
                           uint32_t result, size_t input_rows_count) const = 0;
106
};
107
108
using PreparedFunctionPtr = std::shared_ptr<IPreparedFunction>;
109
110
class PreparedFunctionImpl : public IPreparedFunction {
111
public:
112
    Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
113
                   uint32_t result, size_t input_rows_count) const final;
114
115
    /** If the function have non-zero number of arguments,
116
      *  and if all arguments are constant, that we could automatically provide default implementation:
117
      *  arguments are converted to ordinary columns with single value which is not const, then function is executed as usual,
118
      *  and then the result is converted to constant column.
119
      */
120
1.80M
    virtual bool use_default_implementation_for_constants() const { return true; }
121
122
    /** If use_default_implementation_for_nulls() is true, after execute the function,
123
      * whether need to replace the nested data of null data to the default value.
124
      * E.g. for binary arithmetic exprs, need return true to avoid false overflow.
125
      */
126
0
    virtual bool need_replace_null_data_to_default() const { return false; }
127
128
protected:
129
    virtual Status execute_impl(FunctionContext* context, Block& block,
130
                                const ColumnNumbers& arguments, uint32_t result,
131
                                size_t input_rows_count) const = 0;
132
133
    /** Default implementation in presence of Nullable arguments or NULL constants as arguments is the following:
134
      *  if some of arguments are NULL constants then return NULL constant,
135
      *  if some of arguments are Nullable, then execute function as usual for block,
136
      *   where Nullable columns are substituted with nested columns (they have arbitrary values in rows corresponding to NULL value)
137
      *   and wrap result in Nullable column where NULLs are in all rows where any of arguments are NULL.
138
      */
139
0
    virtual bool use_default_implementation_for_nulls() const { return true; }
140
141
0
    virtual bool skip_return_type_check() const { return false; }
142
143
    /** Some arguments could remain constant during this implementation.
144
      * Every argument required const must write here and no checks elsewhere.
145
      */
146
2.67k
    virtual ColumnNumbers get_arguments_that_are_always_constant() const { return {}; }
147
148
private:
149
    Status default_implementation_for_nulls(FunctionContext* context, Block& block,
150
                                            const ColumnNumbers& args, uint32_t result,
151
                                            size_t input_rows_count, bool* executed) const;
152
    Status default_implementation_for_constant_arguments(FunctionContext* context, Block& block,
153
                                                         const ColumnNumbers& args, uint32_t result,
154
                                                         size_t input_rows_count,
155
                                                         bool* executed) const;
156
    Status default_execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
157
                           uint32_t result, size_t input_rows_count) const;
158
    Status _execute_skipped_constant_deal(FunctionContext* context, Block& block,
159
                                          const ColumnNumbers& args, uint32_t result,
160
                                          size_t input_rows_count) const;
161
};
162
163
/// Function with known arguments and return type.
164
class IFunctionBase {
165
public:
166
1.35M
    virtual ~IFunctionBase() = default;
167
168
    /// Get the main function name.
169
    virtual String get_name() const = 0;
170
171
    virtual const DataTypes& get_argument_types() const = 0;
172
    virtual const DataTypePtr& get_return_type() const = 0;
173
174
2.34k
    virtual double execute_cost() const { return 1.0; }
175
176
    /// Do preparations and return executable.
177
    /// sample_block should contain data types of arguments and values of constants, if relevant.
178
    virtual PreparedFunctionPtr prepare(FunctionContext* context, const Block& sample_block,
179
                                        const ColumnNumbers& arguments, uint32_t result) const = 0;
180
181
    /// Override this when function need to store state in the `FunctionContext`, or do some
182
    /// preparation work according to information from `FunctionContext`.
183
527k
    virtual Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
184
527k
        return Status::OK();
185
527k
    }
186
187
    Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
188
666k
                   uint32_t result, size_t input_rows_count) const {
189
        // Some function implementations may not handle the case where input_rows_count is 0
190
        // (e.g., some functions access the 0th row of input columns during execution).
191
        // Additionally, some UDF functions may hang if they write 0 rows and then try to read.
192
        // Therefore, before executing the function, we first check if input_rows_count is 0.
193
        // If it is 0, we directly return an empty result column to avoid executing the function body.
194
666k
        if (input_rows_count == 0) {
195
417
            block.get_by_position(result).column =
196
417
                    block.get_by_position(result).type->create_column();
197
417
            return Status::OK();
198
417
        }
199
666k
        try {
200
666k
            return prepare(context, block, arguments, result)
201
666k
                    ->execute(context, block, arguments, result, input_rows_count);
202
666k
        } catch (const Exception& e) {
203
304
            return e.to_status();
204
304
        }
205
666k
    }
206
207
    virtual Status evaluate_inverted_index(
208
            const ColumnsWithTypeAndName& arguments,
209
            const std::vector<IndexFieldNameAndTypePair>& data_type_with_names,
210
            std::vector<segment_v2::IndexIterator*> iterators, uint32_t num_rows,
211
            const InvertedIndexAnalyzerCtx* analyzer_ctx,
212
57
            segment_v2::InvertedIndexResultBitmap& bitmap_result) const {
213
57
        return Status::OK();
214
57
    }
215
216
    /// Do cleaning work when function is finished, i.e., release state variables in the
217
    /// `FunctionContext` which are registered in `prepare` phase.
218
2.46M
    virtual Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
219
2.46M
        return Status::OK();
220
2.46M
    }
221
222
    virtual bool is_use_default_implementation_for_constants() const = 0;
223
224
0
    virtual bool is_udf_function() const { return false; }
225
226
1.22k
    virtual bool can_push_down_to_index() const { return false; }
227
228
548k
    virtual bool is_blockable() const { return false; }
229
};
230
231
using FunctionBasePtr = std::shared_ptr<IFunctionBase>;
232
233
/// Creates IFunctionBase from argument types list.
234
class IFunctionBuilder {
235
public:
236
1.36M
    virtual ~IFunctionBuilder() = default;
237
238
    /// Get the main function name.
239
    virtual String get_name() const = 0;
240
241
    /// Override and return true if function could take different number of arguments.
242
    ///TODO: this function is not actually used now. but in check_number_of_arguments we still need it because for many
243
    /// functions we didn't set the correct number of arguments.
244
    virtual bool is_variadic() const = 0;
245
246
    /// For non-variadic functions, return number of arguments; otherwise return zero (that should be ignored).
247
    virtual size_t get_number_of_arguments() const = 0;
248
249
    /// Throw if number of arguments is incorrect. Default implementation will check only in non-variadic case.
250
    virtual void check_number_of_arguments(size_t number_of_arguments) const = 0;
251
252
    /// Check arguments and return IFunctionBase.
253
    virtual FunctionBasePtr build(const ColumnsWithTypeAndName& arguments,
254
                                  const DataTypePtr& return_type) const = 0;
255
256
    /// For higher-order functions (functions, that have lambda expression as at least one argument).
257
    /// You pass data types with empty DataTypeFunction for lambda arguments.
258
    /// This function will replace it with DataTypeFunction containing actual types.
259
    virtual DataTypes get_variadic_argument_types() const = 0;
260
261
    /// Returns indexes of arguments, that must be ColumnConst
262
    virtual ColumnNumbers get_arguments_that_are_always_constant() const = 0;
263
};
264
265
using FunctionBuilderPtr = std::shared_ptr<IFunctionBuilder>;
266
267
3
inline std::string get_types_string(const ColumnsWithTypeAndName& arguments) {
268
3
    std::string types;
269
3
    for (const auto& argument : arguments) {
270
2
        if (!types.empty()) {
271
1
            types += ", ";
272
1
        }
273
2
        types += argument.type->get_name();
274
2
    }
275
3
    return types;
276
3
}
277
278
/// used in function_factory. when we register a function, save a builder. to get a function, to get a builder.
279
/// will use DefaultFunctionBuilder as the default builder in function's registration if we didn't explicitly specify.
280
class FunctionBuilderImpl : public IFunctionBuilder {
281
public:
282
    FunctionBasePtr build(const ColumnsWithTypeAndName& arguments,
283
804k
                          const DataTypePtr& return_type) const final {
284
804k
        if (skip_return_type_check()) {
285
270k
            return build_impl(arguments, return_type);
286
270k
        }
287
533k
        const DataTypePtr& func_return_type = get_return_type(arguments);
288
533k
        if (func_return_type == nullptr) {
289
1
            throw doris::Exception(
290
1
                    ErrorCode::INTERNAL_ERROR,
291
1
                    "function return type check failed, function_name={}, "
292
1
                    "expect_return_type={}, real_return_type is nullptr, input_arguments={}",
293
1
                    get_name(), return_type->get_name(), get_types_string(arguments));
294
1
        }
295
296
        // check return types equal.
297
533k
        if (!(return_type->equals(*func_return_type) ||
298
              // For null constant argument, `get_return_type` would return
299
              // Nullable<DataTypeNothing> when `use_default_implementation_for_nulls` is true.
300
533k
              (return_type->is_nullable() && func_return_type->is_nullable() &&
301
1.98k
               ((DataTypeNullable*)func_return_type.get())
302
992
                               ->get_nested_type()
303
992
                               ->get_primitive_type() == INVALID_TYPE) ||
304
533k
              is_date_or_datetime_or_decimal(return_type, func_return_type) ||
305
533k
              is_nested_type_date_or_datetime_or_decimal(return_type, func_return_type))) {
306
2
            throw doris::Exception(
307
2
                    ErrorCode::INTERNAL_ERROR,
308
2
                    "function return type check failed, function_name={}, "
309
2
                    "fe plan return type={},  be real return type={}, input_arguments={}",
310
2
                    get_name(), return_type->get_name(), func_return_type->get_name(),
311
2
                    get_types_string(arguments));
312
2
        }
313
533k
        return build_impl(arguments, return_type);
314
533k
    }
315
316
456k
    bool is_variadic() const override { return false; }
317
318
    // Default implementation. Will check only in non-variadic case.
319
    void check_number_of_arguments(size_t number_of_arguments) const override;
320
    // the return type should be same with what FE plans.
321
    // it returns: `get_return_type_impl` if `use_default_implementation_for_nulls` = false
322
    //  `get_return_type_impl` warpped in NULL if `use_default_implementation_for_nulls` = true and input has NULL
323
    DataTypePtr get_return_type(const ColumnsWithTypeAndName& arguments) const;
324
325
9.32k
    DataTypes get_variadic_argument_types() const override {
326
9.32k
        return get_variadic_argument_types_impl();
327
9.32k
    }
328
329
0
    ColumnNumbers get_arguments_that_are_always_constant() const override { return {}; }
330
331
protected:
332
    // Get the result type by argument type. If the function does not apply to these arguments, throw an exception.
333
    // the get_return_type_impl and its overrides should only return the nested type if `use_default_implementation_for_nulls` is true.
334
    // whether to wrap in nullable type will be automatically decided.
335
529k
    virtual DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const {
336
529k
        DataTypes data_types(arguments.size());
337
1.57M
        for (size_t i = 0; i < arguments.size(); ++i) {
338
1.04M
            data_types[i] = arguments[i].type;
339
1.04M
        }
340
529k
        return get_return_type_impl(data_types);
341
529k
    }
342
343
0
    virtual DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) const {
344
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
345
0
                               "get_return_type is not implemented for {}", get_name());
346
0
        return nullptr;
347
0
    }
348
349
    /** If use_default_implementation_for_nulls() is true, than change arguments for get_return_type() and build_impl():
350
      *  if some of arguments are Nullable(Nothing) then don't call get_return_type(), call build_impl() with return_type = Nullable(Nothing),
351
      *  if some of arguments are Nullable, then:
352
      *   - Nullable types are substituted with nested types for get_return_type() function
353
      *   - WRAP get_return_type() RESULT IN NULLABLE type and pass to build_impl
354
      *
355
      * Otherwise build returns build_impl(arguments, get_return_type(arguments));
356
      */
357
0
    virtual bool use_default_implementation_for_nulls() const { return true; }
358
359
13
    virtual bool skip_return_type_check() const { return false; }
360
361
0
    virtual bool need_replace_null_data_to_default() const { return false; }
362
363
    /// return a real function object to execute. called in build(...).
364
    virtual FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments,
365
                                       const DataTypePtr& return_type) const = 0;
366
367
2.79k
    virtual DataTypes get_variadic_argument_types_impl() const { return {}; }
368
369
private:
370
    bool is_date_or_datetime_or_decimal(const DataTypePtr& return_type,
371
                                        const DataTypePtr& func_return_type) const;
372
    bool is_nested_type_date_or_datetime_or_decimal(const DataTypePtr& return_type,
373
                                                    const DataTypePtr& func_return_type) const;
374
};
375
376
/// Previous function interface.
377
class IFunction : public std::enable_shared_from_this<IFunction>,
378
                  public FunctionBuilderImpl,
379
                  public IFunctionBase,
380
                  public PreparedFunctionImpl {
381
public:
382
    String get_name() const override = 0;
383
384
    /// Notice: We should not change the column in the block, because the column may be shared by multiple expressions or exec nodes.
385
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
386
                        uint32_t result, size_t input_rows_count) const override = 0;
387
388
    /// Override this functions to change default implementation behavior. See details in IMyFunction.
389
796k
    bool use_default_implementation_for_nulls() const override { return true; }
390
391
533k
    bool skip_return_type_check() const override { return false; }
392
393
96.0k
    bool need_replace_null_data_to_default() const override { return false; }
394
395
    /// all constancy check should use this function to do automatically
396
420k
    ColumnNumbers get_arguments_that_are_always_constant() const override { return {}; }
397
398
1.33M
    bool is_use_default_implementation_for_constants() const override {
399
1.33M
        return use_default_implementation_for_constants();
400
1.33M
    }
401
402
    using PreparedFunctionImpl::execute;
403
    using FunctionBuilderImpl::get_return_type_impl;
404
    using FunctionBuilderImpl::get_variadic_argument_types_impl;
405
    using FunctionBuilderImpl::get_return_type;
406
407
    [[noreturn]] PreparedFunctionPtr prepare(FunctionContext* context,
408
                                             const Block& /*sample_block*/,
409
                                             const ColumnNumbers& /*arguments*/,
410
0
                                             uint32_t /*result*/) const final {
411
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
412
0
                               "prepare is not implemented for IFunction {}", get_name());
413
0
        __builtin_unreachable();
414
0
    }
415
416
1.89M
    Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) override {
417
1.89M
        return Status::OK();
418
1.89M
    }
419
420
0
    [[noreturn]] const DataTypes& get_argument_types() const final {
421
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
422
0
                               "get_argument_types is not implemented for IFunction {}",
423
0
                               get_name());
424
0
        __builtin_unreachable();
425
0
    }
426
427
0
    [[noreturn]] const DataTypePtr& get_return_type() const final {
428
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
429
0
                               "get_return_type is not implemented for IFunction {}", get_name());
430
0
        __builtin_unreachable();
431
0
    }
432
433
protected:
434
    FunctionBasePtr build_impl(const ColumnsWithTypeAndName& /*arguments*/,
435
0
                               const DataTypePtr& /*return_type*/) const final {
436
0
        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
437
0
                               "build_impl is not implemented for IFunction {}", get_name());
438
0
        __builtin_unreachable();
439
0
        return {};
440
0
    }
441
};
442
443
/*
444
 * when we register a function which didn't specify its base(i.e. inherited from IFunction), actually we use this as a wrapper.
445
 * it saves real implementation as `function`. 
446
*/
447
class DefaultFunction final : public IFunctionBase {
448
public:
449
    DefaultFunction(std::shared_ptr<IFunction> function_, DataTypes arguments_,
450
                    DataTypePtr return_type_)
451
535k
            : function(std::move(function_)),
452
535k
              arguments(std::move(arguments_)),
453
535k
              return_type(std::move(return_type_)) {}
454
455
263
    String get_name() const override { return function->get_name(); }
456
457
0
    const DataTypes& get_argument_types() const override { return arguments; }
458
1
    const DataTypePtr& get_return_type() const override { return return_type; }
459
460
    // return a default wrapper for IFunction.
461
    PreparedFunctionPtr prepare(FunctionContext* context, const Block& /*sample_block*/,
462
                                const ColumnNumbers& /*arguments*/,
463
306k
                                uint32_t /*result*/) const override {
464
306k
        return function;
465
306k
    }
466
467
686k
    double execute_cost() const override { return function->execute_cost(); }
468
469
1.98M
    Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) override {
470
1.98M
        return function->open(context, scope);
471
1.98M
    }
472
473
1.98M
    Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) override {
474
1.98M
        return function->close(context, scope);
475
1.98M
    }
476
477
    Status evaluate_inverted_index(
478
            const ColumnsWithTypeAndName& args,
479
            const std::vector<IndexFieldNameAndTypePair>& data_type_with_names,
480
            std::vector<segment_v2::IndexIterator*> iterators, uint32_t num_rows,
481
            const InvertedIndexAnalyzerCtx* analyzer_ctx,
482
8.46k
            segment_v2::InvertedIndexResultBitmap& bitmap_result) const override {
483
8.46k
        return function->evaluate_inverted_index(args, data_type_with_names, iterators, num_rows,
484
8.46k
                                                 analyzer_ctx, bitmap_result);
485
8.46k
    }
486
487
1.33M
    bool is_use_default_implementation_for_constants() const override {
488
1.33M
        return function->is_use_default_implementation_for_constants();
489
1.33M
    }
490
491
1.22k
    bool can_push_down_to_index() const override { return function->can_push_down_to_index(); }
492
493
547k
    bool is_blockable() const override { return function->is_blockable(); }
494
495
private:
496
    std::shared_ptr<IFunction> function;
497
    DataTypes arguments;
498
    DataTypePtr return_type;
499
};
500
501
struct simple_function_creator_without_type0 {
502
    template <typename AggregateFunctionTemplate, typename... TArgs>
503
171
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
171
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
171
                result_type, std::forward<TArgs>(args)...));
506
171
        return std::shared_ptr<IFunction>(result.release());
507
171
    }
_ZN5doris37simple_function_creator_without_type06createINS_25FunctionArrayAggDecimalV3INS_27ArrayAggregateImplDecimalV3ILNS_18AggregateOperationE2ELNS_13PrimitiveTypeE30EEENS_12NameArraySumEEEJEEESt10shared_ptrINS_9IFunctionEERKS9_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
12
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
12
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
12
                result_type, std::forward<TArgs>(args)...));
506
12
        return std::shared_ptr<IFunction>(result.release());
507
12
    }
_ZN5doris37simple_function_creator_without_type06createINS_25FunctionArrayAggDecimalV3INS_27ArrayAggregateImplDecimalV3ILNS_18AggregateOperationE2ELNS_13PrimitiveTypeE35EEENS_12NameArraySumEEEJEEESt10shared_ptrINS_9IFunctionEERKS9_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
29
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
29
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
29
                result_type, std::forward<TArgs>(args)...));
506
29
        return std::shared_ptr<IFunction>(result.release());
507
29
    }
_ZN5doris37simple_function_creator_without_type06createINS_25FunctionArrayAggDecimalV3INS_27ArrayAggregateImplDecimalV3ILNS_18AggregateOperationE3ELNS_13PrimitiveTypeE30EEENS_16NameArrayAverageEEEJEEESt10shared_ptrINS_9IFunctionEERKS9_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
11
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
11
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
11
                result_type, std::forward<TArgs>(args)...));
506
11
        return std::shared_ptr<IFunction>(result.release());
507
11
    }
_ZN5doris37simple_function_creator_without_type06createINS_25FunctionArrayAggDecimalV3INS_27ArrayAggregateImplDecimalV3ILNS_18AggregateOperationE3ELNS_13PrimitiveTypeE35EEENS_16NameArrayAverageEEEJEEESt10shared_ptrINS_9IFunctionEERKS9_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
31
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
31
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
31
                result_type, std::forward<TArgs>(args)...));
506
31
        return std::shared_ptr<IFunction>(result.release());
507
31
    }
_ZN5doris37simple_function_creator_without_type06createINS_25FunctionArrayAggDecimalV3INS_27ArrayAggregateImplDecimalV3ILNS_18AggregateOperationE4ELNS_13PrimitiveTypeE30EEENS_16NameArrayProductEEEJEEESt10shared_ptrINS_9IFunctionEERKS9_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
12
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
12
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
12
                result_type, std::forward<TArgs>(args)...));
506
12
        return std::shared_ptr<IFunction>(result.release());
507
12
    }
_ZN5doris37simple_function_creator_without_type06createINS_25FunctionArrayAggDecimalV3INS_27ArrayAggregateImplDecimalV3ILNS_18AggregateOperationE4ELNS_13PrimitiveTypeE35EEENS_16NameArrayProductEEEJEEESt10shared_ptrINS_9IFunctionEERKS9_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
31
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
31
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
31
                result_type, std::forward<TArgs>(args)...));
506
31
        return std::shared_ptr<IFunction>(result.release());
507
31
    }
_ZN5doris37simple_function_creator_without_type06createINS_19FunctionArrayCumSumILNS_13PrimitiveTypeE30EEEJEEESt10shared_ptrINS_9IFunctionEERKS5_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
14
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
14
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
14
                result_type, std::forward<TArgs>(args)...));
506
14
        return std::shared_ptr<IFunction>(result.release());
507
14
    }
_ZN5doris37simple_function_creator_without_type06createINS_19FunctionArrayCumSumILNS_13PrimitiveTypeE35EEEJEEESt10shared_ptrINS_9IFunctionEERKS5_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
503
31
    static std::shared_ptr<IFunction> create(const DataTypePtr& result_type, TArgs&&... args) {
504
31
        std::unique_ptr<IFunction> result(std::make_unique<AggregateFunctionTemplate>(
505
31
                result_type, std::forward<TArgs>(args)...));
506
31
        return std::shared_ptr<IFunction>(result.release());
507
31
    }
508
};
509
template <template <PrimitiveType> class FunctionTemplate>
510
struct SimpleFunctionCurryDirectWithResultType0 {
511
    template <PrimitiveType ResultType>
512
    using T = FunctionTemplate<ResultType>;
513
};
514
template <PrimitiveType... AllowedTypes>
515
struct simple_function_creator_with_result_type0 {
516
    template <typename Class, typename... TArgs>
517
    static std::shared_ptr<IFunction> create_base_with_result_type(const DataTypePtr& result_type,
518
171
                                                                   TArgs&&... args) {
519
171
        auto create = [&]<PrimitiveType ResultType>() {
520
171
            return simple_function_creator_without_type0::create<
521
171
                    typename Class::template T<ResultType>>(result_type,
522
171
                                                            std::forward<TArgs>(args)...);
523
171
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArraySumDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_30EEEDav
Line
Count
Source
519
12
        auto create = [&]<PrimitiveType ResultType>() {
520
12
            return simple_function_creator_without_type0::create<
521
12
                    typename Class::template T<ResultType>>(result_type,
522
12
                                                            std::forward<TArgs>(args)...);
523
12
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArraySumDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_35EEEDav
Line
Count
Source
519
29
        auto create = [&]<PrimitiveType ResultType>() {
520
29
            return simple_function_creator_without_type0::create<
521
29
                    typename Class::template T<ResultType>>(result_type,
522
29
                                                            std::forward<TArgs>(args)...);
523
29
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArrayAvgDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_30EEEDav
Line
Count
Source
519
11
        auto create = [&]<PrimitiveType ResultType>() {
520
11
            return simple_function_creator_without_type0::create<
521
11
                    typename Class::template T<ResultType>>(result_type,
522
11
                                                            std::forward<TArgs>(args)...);
523
11
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArrayAvgDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_35EEEDav
Line
Count
Source
519
31
        auto create = [&]<PrimitiveType ResultType>() {
520
31
            return simple_function_creator_without_type0::create<
521
31
                    typename Class::template T<ResultType>>(result_type,
522
31
                                                            std::forward<TArgs>(args)...);
523
31
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_21ArrayProductDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_30EEEDav
Line
Count
Source
519
12
        auto create = [&]<PrimitiveType ResultType>() {
520
12
            return simple_function_creator_without_type0::create<
521
12
                    typename Class::template T<ResultType>>(result_type,
522
12
                                                            std::forward<TArgs>(args)...);
523
12
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_21ArrayProductDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_35EEEDav
Line
Count
Source
519
31
        auto create = [&]<PrimitiveType ResultType>() {
520
31
            return simple_function_creator_without_type0::create<
521
31
                    typename Class::template T<ResultType>>(result_type,
522
31
                                                            std::forward<TArgs>(args)...);
523
31
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_19FunctionArrayCumSumEEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_30EEEDav
Line
Count
Source
519
14
        auto create = [&]<PrimitiveType ResultType>() {
520
14
            return simple_function_creator_without_type0::create<
521
14
                    typename Class::template T<ResultType>>(result_type,
522
14
                                                            std::forward<TArgs>(args)...);
523
14
        };
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_19FunctionArrayCumSumEEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlTnS1_vE_clILS1_35EEEDav
Line
Count
Source
519
31
        auto create = [&]<PrimitiveType ResultType>() {
520
31
            return simple_function_creator_without_type0::create<
521
31
                    typename Class::template T<ResultType>>(result_type,
522
31
                                                            std::forward<TArgs>(args)...);
523
31
        };
524
171
        std::shared_ptr<IFunction> result = nullptr;
525
171
        auto type = result_type->get_primitive_type();
526
527
171
        (
528
342
                [&] {
529
342
                    if (type == AllowedTypes) {
530
171
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
171
                                      AllowedTypes == TYPE_DECIMAL256);
532
171
                        result = create.template operator()<AllowedTypes>();
533
171
                    }
534
342
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArraySumDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE0_clEv
Line
Count
Source
528
41
                [&] {
529
41
                    if (type == AllowedTypes) {
530
12
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
12
                                      AllowedTypes == TYPE_DECIMAL256);
532
12
                        result = create.template operator()<AllowedTypes>();
533
12
                    }
534
41
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArraySumDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE_clEv
Line
Count
Source
528
41
                [&] {
529
41
                    if (type == AllowedTypes) {
530
29
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
29
                                      AllowedTypes == TYPE_DECIMAL256);
532
29
                        result = create.template operator()<AllowedTypes>();
533
29
                    }
534
41
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArrayAvgDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE0_clEv
Line
Count
Source
528
42
                [&] {
529
42
                    if (type == AllowedTypes) {
530
11
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
11
                                      AllowedTypes == TYPE_DECIMAL256);
532
11
                        result = create.template operator()<AllowedTypes>();
533
11
                    }
534
42
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArrayAvgDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE_clEv
Line
Count
Source
528
42
                [&] {
529
42
                    if (type == AllowedTypes) {
530
31
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
31
                                      AllowedTypes == TYPE_DECIMAL256);
532
31
                        result = create.template operator()<AllowedTypes>();
533
31
                    }
534
42
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_21ArrayProductDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE0_clEv
Line
Count
Source
528
43
                [&] {
529
43
                    if (type == AllowedTypes) {
530
12
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
12
                                      AllowedTypes == TYPE_DECIMAL256);
532
12
                        result = create.template operator()<AllowedTypes>();
533
12
                    }
534
43
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_21ArrayProductDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE_clEv
Line
Count
Source
528
43
                [&] {
529
43
                    if (type == AllowedTypes) {
530
31
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
31
                                      AllowedTypes == TYPE_DECIMAL256);
532
31
                        result = create.template operator()<AllowedTypes>();
533
31
                    }
534
43
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_19FunctionArrayCumSumEEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE0_clEv
Line
Count
Source
528
45
                [&] {
529
45
                    if (type == AllowedTypes) {
530
14
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
14
                                      AllowedTypes == TYPE_DECIMAL256);
532
14
                        result = create.template operator()<AllowedTypes>();
533
14
                    }
534
45
                }(),
_ZZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_19FunctionArrayCumSumEEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_ENKUlvE_clEv
Line
Count
Source
528
45
                [&] {
529
45
                    if (type == AllowedTypes) {
530
31
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
31
                                      AllowedTypes == TYPE_DECIMAL256);
532
31
                        result = create.template operator()<AllowedTypes>();
533
31
                    }
534
45
                }(),
535
171
                ...);
536
537
171
        return result;
538
171
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArraySumDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
518
41
                                                                   TArgs&&... args) {
519
41
        auto create = [&]<PrimitiveType ResultType>() {
520
41
            return simple_function_creator_without_type0::create<
521
41
                    typename Class::template T<ResultType>>(result_type,
522
41
                                                            std::forward<TArgs>(args)...);
523
41
        };
524
41
        std::shared_ptr<IFunction> result = nullptr;
525
41
        auto type = result_type->get_primitive_type();
526
527
41
        (
528
41
                [&] {
529
41
                    if (type == AllowedTypes) {
530
41
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
41
                                      AllowedTypes == TYPE_DECIMAL256);
532
41
                        result = create.template operator()<AllowedTypes>();
533
41
                    }
534
41
                }(),
535
41
                ...);
536
537
41
        return result;
538
41
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_17ArrayAvgDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
518
42
                                                                   TArgs&&... args) {
519
42
        auto create = [&]<PrimitiveType ResultType>() {
520
42
            return simple_function_creator_without_type0::create<
521
42
                    typename Class::template T<ResultType>>(result_type,
522
42
                                                            std::forward<TArgs>(args)...);
523
42
        };
524
42
        std::shared_ptr<IFunction> result = nullptr;
525
42
        auto type = result_type->get_primitive_type();
526
527
42
        (
528
42
                [&] {
529
42
                    if (type == AllowedTypes) {
530
42
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
42
                                      AllowedTypes == TYPE_DECIMAL256);
532
42
                        result = create.template operator()<AllowedTypes>();
533
42
                    }
534
42
                }(),
535
42
                ...);
536
537
42
        return result;
538
42
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_21ArrayProductDecimalV3EEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
518
43
                                                                   TArgs&&... args) {
519
43
        auto create = [&]<PrimitiveType ResultType>() {
520
43
            return simple_function_creator_without_type0::create<
521
43
                    typename Class::template T<ResultType>>(result_type,
522
43
                                                            std::forward<TArgs>(args)...);
523
43
        };
524
43
        std::shared_ptr<IFunction> result = nullptr;
525
43
        auto type = result_type->get_primitive_type();
526
527
43
        (
528
43
                [&] {
529
43
                    if (type == AllowedTypes) {
530
43
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
43
                                      AllowedTypes == TYPE_DECIMAL256);
532
43
                        result = create.template operator()<AllowedTypes>();
533
43
                    }
534
43
                }(),
535
43
                ...);
536
537
43
        return result;
538
43
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE28create_base_with_result_typeINS_40SimpleFunctionCurryDirectWithResultType0INS_19FunctionArrayCumSumEEEJEEESt10shared_ptrINS_9IFunctionEERKS7_IKNS_9IDataTypeEEDpOT0_
Line
Count
Source
518
45
                                                                   TArgs&&... args) {
519
45
        auto create = [&]<PrimitiveType ResultType>() {
520
45
            return simple_function_creator_without_type0::create<
521
45
                    typename Class::template T<ResultType>>(result_type,
522
45
                                                            std::forward<TArgs>(args)...);
523
45
        };
524
45
        std::shared_ptr<IFunction> result = nullptr;
525
45
        auto type = result_type->get_primitive_type();
526
527
45
        (
528
45
                [&] {
529
45
                    if (type == AllowedTypes) {
530
45
                        static_assert(AllowedTypes == TYPE_DECIMAL128I ||
531
45
                                      AllowedTypes == TYPE_DECIMAL256);
532
45
                        result = create.template operator()<AllowedTypes>();
533
45
                    }
534
45
                }(),
535
45
                ...);
536
537
45
        return result;
538
45
    }
539
540
    // Create agg function with result type from FE.
541
    // Currently only used for decimalv3 sum and avg.
542
    template <template <PrimitiveType> class FunctionTemplate>
543
171
    static std::shared_ptr<IFunction> creator_with_result_type(const DataTypePtr& result_type) {
544
171
        return create_base_with_result_type<
545
171
                SimpleFunctionCurryDirectWithResultType0<FunctionTemplate>>(result_type);
546
171
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE24creator_with_result_typeINS_17ArraySumDecimalV3EEESt10shared_ptrINS_9IFunctionEERKS5_IKNS_9IDataTypeEE
Line
Count
Source
543
41
    static std::shared_ptr<IFunction> creator_with_result_type(const DataTypePtr& result_type) {
544
41
        return create_base_with_result_type<
545
41
                SimpleFunctionCurryDirectWithResultType0<FunctionTemplate>>(result_type);
546
41
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE24creator_with_result_typeINS_17ArrayAvgDecimalV3EEESt10shared_ptrINS_9IFunctionEERKS5_IKNS_9IDataTypeEE
Line
Count
Source
543
42
    static std::shared_ptr<IFunction> creator_with_result_type(const DataTypePtr& result_type) {
544
42
        return create_base_with_result_type<
545
42
                SimpleFunctionCurryDirectWithResultType0<FunctionTemplate>>(result_type);
546
42
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE24creator_with_result_typeINS_21ArrayProductDecimalV3EEESt10shared_ptrINS_9IFunctionEERKS5_IKNS_9IDataTypeEE
Line
Count
Source
543
43
    static std::shared_ptr<IFunction> creator_with_result_type(const DataTypePtr& result_type) {
544
43
        return create_base_with_result_type<
545
43
                SimpleFunctionCurryDirectWithResultType0<FunctionTemplate>>(result_type);
546
43
    }
_ZN5doris41simple_function_creator_with_result_type0IJLNS_13PrimitiveTypeE30ELS1_35EEE24creator_with_result_typeINS_19FunctionArrayCumSumEEESt10shared_ptrINS_9IFunctionEERKS5_IKNS_9IDataTypeEE
Line
Count
Source
543
45
    static std::shared_ptr<IFunction> creator_with_result_type(const DataTypePtr& result_type) {
544
45
        return create_base_with_result_type<
545
45
                SimpleFunctionCurryDirectWithResultType0<FunctionTemplate>>(result_type);
546
45
    }
547
};
548
549
class DefaultFunctionBuilder : public FunctionBuilderImpl {
550
public:
551
    explicit DefaultFunctionBuilder(std::shared_ptr<IFunction> function_)
552
544k
            : function(std::move(function_)) {}
553
554
    // template <template <PrimitiveType> class FunctionTemplate>
555
    explicit DefaultFunctionBuilder(DataTypePtr return_type)
556
171
            : _return_type(std::move(return_type)) {}
557
558
    template <template <PrimitiveType> class FunctionTemplate>
559
171
    static FunctionBuilderPtr create_array_agg_function_decimalv3(DataTypePtr return_type) {
560
171
        auto builder = std::make_shared<DefaultFunctionBuilder>(return_type);
561
171
        DataTypePtr real_return_type;
562
        // for array_cum_sum, the return type is array,
563
        // so here should check nested type
564
171
        if (PrimitiveType::TYPE_ARRAY == return_type->get_primitive_type()) {
565
45
            const DataTypeArray* data_type_array =
566
45
                    static_cast<const DataTypeArray*>(remove_nullable(return_type).get());
567
45
            real_return_type = data_type_array->get_nested_type();
568
126
        } else {
569
126
            real_return_type = return_type;
570
126
        }
571
171
        builder->function =
572
171
                simple_function_creator_with_result_type0<TYPE_DECIMAL128I, TYPE_DECIMAL256>::
573
171
                        creator_with_result_type<FunctionTemplate>(real_return_type);
574
171
        return builder;
575
171
    }
_ZN5doris22DefaultFunctionBuilder35create_array_agg_function_decimalv3INS_17ArraySumDecimalV3EEESt10shared_ptrINS_16IFunctionBuilderEES3_IKNS_9IDataTypeEE
Line
Count
Source
559
41
    static FunctionBuilderPtr create_array_agg_function_decimalv3(DataTypePtr return_type) {
560
41
        auto builder = std::make_shared<DefaultFunctionBuilder>(return_type);
561
41
        DataTypePtr real_return_type;
562
        // for array_cum_sum, the return type is array,
563
        // so here should check nested type
564
41
        if (PrimitiveType::TYPE_ARRAY == return_type->get_primitive_type()) {
565
0
            const DataTypeArray* data_type_array =
566
0
                    static_cast<const DataTypeArray*>(remove_nullable(return_type).get());
567
0
            real_return_type = data_type_array->get_nested_type();
568
41
        } else {
569
41
            real_return_type = return_type;
570
41
        }
571
41
        builder->function =
572
41
                simple_function_creator_with_result_type0<TYPE_DECIMAL128I, TYPE_DECIMAL256>::
573
41
                        creator_with_result_type<FunctionTemplate>(real_return_type);
574
41
        return builder;
575
41
    }
_ZN5doris22DefaultFunctionBuilder35create_array_agg_function_decimalv3INS_17ArrayAvgDecimalV3EEESt10shared_ptrINS_16IFunctionBuilderEES3_IKNS_9IDataTypeEE
Line
Count
Source
559
42
    static FunctionBuilderPtr create_array_agg_function_decimalv3(DataTypePtr return_type) {
560
42
        auto builder = std::make_shared<DefaultFunctionBuilder>(return_type);
561
42
        DataTypePtr real_return_type;
562
        // for array_cum_sum, the return type is array,
563
        // so here should check nested type
564
42
        if (PrimitiveType::TYPE_ARRAY == return_type->get_primitive_type()) {
565
0
            const DataTypeArray* data_type_array =
566
0
                    static_cast<const DataTypeArray*>(remove_nullable(return_type).get());
567
0
            real_return_type = data_type_array->get_nested_type();
568
42
        } else {
569
42
            real_return_type = return_type;
570
42
        }
571
42
        builder->function =
572
42
                simple_function_creator_with_result_type0<TYPE_DECIMAL128I, TYPE_DECIMAL256>::
573
42
                        creator_with_result_type<FunctionTemplate>(real_return_type);
574
42
        return builder;
575
42
    }
_ZN5doris22DefaultFunctionBuilder35create_array_agg_function_decimalv3INS_21ArrayProductDecimalV3EEESt10shared_ptrINS_16IFunctionBuilderEES3_IKNS_9IDataTypeEE
Line
Count
Source
559
43
    static FunctionBuilderPtr create_array_agg_function_decimalv3(DataTypePtr return_type) {
560
43
        auto builder = std::make_shared<DefaultFunctionBuilder>(return_type);
561
43
        DataTypePtr real_return_type;
562
        // for array_cum_sum, the return type is array,
563
        // so here should check nested type
564
43
        if (PrimitiveType::TYPE_ARRAY == return_type->get_primitive_type()) {
565
0
            const DataTypeArray* data_type_array =
566
0
                    static_cast<const DataTypeArray*>(remove_nullable(return_type).get());
567
0
            real_return_type = data_type_array->get_nested_type();
568
43
        } else {
569
43
            real_return_type = return_type;
570
43
        }
571
43
        builder->function =
572
43
                simple_function_creator_with_result_type0<TYPE_DECIMAL128I, TYPE_DECIMAL256>::
573
43
                        creator_with_result_type<FunctionTemplate>(real_return_type);
574
43
        return builder;
575
43
    }
_ZN5doris22DefaultFunctionBuilder35create_array_agg_function_decimalv3INS_19FunctionArrayCumSumEEESt10shared_ptrINS_16IFunctionBuilderEES3_IKNS_9IDataTypeEE
Line
Count
Source
559
45
    static FunctionBuilderPtr create_array_agg_function_decimalv3(DataTypePtr return_type) {
560
45
        auto builder = std::make_shared<DefaultFunctionBuilder>(return_type);
561
45
        DataTypePtr real_return_type;
562
        // for array_cum_sum, the return type is array,
563
        // so here should check nested type
564
45
        if (PrimitiveType::TYPE_ARRAY == return_type->get_primitive_type()) {
565
45
            const DataTypeArray* data_type_array =
566
45
                    static_cast<const DataTypeArray*>(remove_nullable(return_type).get());
567
45
            real_return_type = data_type_array->get_nested_type();
568
45
        } else {
569
0
            real_return_type = return_type;
570
0
        }
571
45
        builder->function =
572
45
                simple_function_creator_with_result_type0<TYPE_DECIMAL128I, TYPE_DECIMAL256>::
573
45
                        creator_with_result_type<FunctionTemplate>(real_return_type);
574
45
        return builder;
575
45
    }
576
577
533k
    void check_number_of_arguments(size_t number_of_arguments) const override {
578
533k
        function->check_number_of_arguments(number_of_arguments);
579
533k
    }
580
581
502
    String get_name() const override { return function->get_name(); }
582
1.14k
    bool is_variadic() const override { return function->is_variadic(); }
583
0
    size_t get_number_of_arguments() const override { return function->get_number_of_arguments(); }
584
585
0
    ColumnNumbers get_arguments_that_are_always_constant() const override {
586
0
        return function->get_arguments_that_are_always_constant();
587
0
    }
588
589
protected:
590
0
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
591
0
        return function->get_return_type_impl(arguments);
592
0
    }
593
533k
    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
594
533k
        return function->get_return_type_impl(arguments);
595
533k
    }
596
597
532k
    bool use_default_implementation_for_nulls() const override {
598
532k
        return function->use_default_implementation_for_nulls();
599
532k
    }
600
601
534k
    bool skip_return_type_check() const override { return function->skip_return_type_check(); }
602
603
0
    bool need_replace_null_data_to_default() const override {
604
0
        return function->need_replace_null_data_to_default();
605
0
    }
606
607
    FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments,
608
533k
                               const DataTypePtr& return_type) const override {
609
533k
        DataTypes data_types(arguments.size());
610
1.58M
        for (size_t i = 0; i < arguments.size(); ++i) {
611
1.04M
            data_types[i] = arguments[i].type;
612
1.04M
        }
613
533k
        return std::make_shared<DefaultFunction>(function, data_types, return_type);
614
533k
    }
615
616
9.30k
    DataTypes get_variadic_argument_types_impl() const override {
617
9.30k
        return function->get_variadic_argument_types_impl();
618
9.30k
    }
619
620
private:
621
    std::shared_ptr<IFunction> function;
622
    DataTypePtr _return_type;
623
};
624
625
using FunctionPtr = std::shared_ptr<IFunction>;
626
/** Return ColumnNullable of src, with null map as OR-ed null maps of args columns in blocks.
627
  * Or ColumnConst(ColumnNullable) if the result is always NULL or if the result is constant and always not NULL.
628
  */
629
ColumnPtr wrap_in_nullable(const ColumnPtr& src, const Block& block, const ColumnNumbers& args,
630
                           size_t input_rows_count);
631
632
} // namespace doris