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