be/src/exprs/function/function_variadic_arguments.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | #include <utility> |
20 | | |
21 | | #include "common/status.h" |
22 | | #include "core/column/column_string.h" |
23 | | #include "core/column/column_vector.h" |
24 | | #include "core/data_type/data_type.h" |
25 | | #include "core/data_type/data_type_decimal.h" |
26 | | #include "core/data_type/data_type_number.h" |
27 | | #include "exprs/function/function.h" |
28 | | #include "exprs/function/function_helpers.h" |
29 | | |
30 | | namespace doris { |
31 | | |
32 | | template <typename ToDataType, typename Impl> |
33 | | class FunctionVariadicArgumentsBase : public IFunction { |
34 | | public: |
35 | | static constexpr auto name = Impl::name; |
36 | 0 | String get_name() const override { return name; }Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15MurmurHash3ImplILS2_5ELb0EEEE8get_nameB5cxx11Ev Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb0EEEE8get_nameB5cxx11Ev Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb1EEEE8get_nameB5cxx11Ev Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_10XxHashImplILS2_5EEEE8get_nameB5cxx11Ev Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_10XxHashImplILS2_6EEEE8get_nameB5cxx11Ev |
37 | 212 | static FunctionPtr create() { return std::make_shared<FunctionVariadicArgumentsBase>(); }_ZN5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15MurmurHash3ImplILS2_5ELb0EEEE6createEv Line | Count | Source | 37 | 20 | static FunctionPtr create() { return std::make_shared<FunctionVariadicArgumentsBase>(); } |
_ZN5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb0EEEE6createEv Line | Count | Source | 37 | 20 | static FunctionPtr create() { return std::make_shared<FunctionVariadicArgumentsBase>(); } |
_ZN5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb1EEEE6createEv Line | Count | Source | 37 | 13 | static FunctionPtr create() { return std::make_shared<FunctionVariadicArgumentsBase>(); } |
_ZN5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_10XxHashImplILS2_5EEEE6createEv Line | Count | Source | 37 | 56 | static FunctionPtr create() { return std::make_shared<FunctionVariadicArgumentsBase>(); } |
_ZN5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_10XxHashImplILS2_6EEEE6createEv Line | Count | Source | 37 | 103 | static FunctionPtr create() { return std::make_shared<FunctionVariadicArgumentsBase>(); } |
|
38 | 172 | bool is_variadic() const override { return true; }_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15MurmurHash3ImplILS2_5ELb0EEEE11is_variadicEv Line | Count | Source | 38 | 12 | bool is_variadic() const override { return true; } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb0EEEE11is_variadicEv Line | Count | Source | 38 | 12 | bool is_variadic() const override { return true; } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb1EEEE11is_variadicEv Line | Count | Source | 38 | 5 | bool is_variadic() const override { return true; } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_10XxHashImplILS2_5EEEE11is_variadicEv Line | Count | Source | 38 | 48 | bool is_variadic() const override { return true; } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_10XxHashImplILS2_6EEEE11is_variadicEv Line | Count | Source | 38 | 95 | bool is_variadic() const override { return true; } |
|
39 | 0 | size_t get_number_of_arguments() const override { return 0; }Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15MurmurHash3ImplILS2_5ELb0EEEE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb0EEEE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb1EEEE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_10XxHashImplILS2_5EEEE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_10XxHashImplILS2_6EEEE23get_number_of_argumentsEv |
40 | | |
41 | 167 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { |
42 | 167 | DataTypePtr res; |
43 | | if constexpr (IsDataTypeDecimalV2<ToDataType>) { |
44 | | res = create_decimal(27, 9, true); |
45 | | if (!res) { |
46 | | throw doris::Exception(ErrorCode::INVALID_ARGUMENT, |
47 | | "Something wrong with create_decimal in function {}", |
48 | | get_name()); |
49 | | __builtin_unreachable(); |
50 | | } |
51 | 167 | } else { |
52 | 167 | res = std::make_shared<ToDataType>(); |
53 | 167 | } |
54 | 167 | return res; |
55 | 167 | } _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15MurmurHash3ImplILS2_5ELb0EEEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS8_EE Line | Count | Source | 41 | 11 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 42 | 11 | DataTypePtr res; | 43 | | if constexpr (IsDataTypeDecimalV2<ToDataType>) { | 44 | | res = create_decimal(27, 9, true); | 45 | | if (!res) { | 46 | | throw doris::Exception(ErrorCode::INVALID_ARGUMENT, | 47 | | "Something wrong with create_decimal in function {}", | 48 | | get_name()); | 49 | | __builtin_unreachable(); | 50 | | } | 51 | 11 | } else { | 52 | 11 | res = std::make_shared<ToDataType>(); | 53 | 11 | } | 54 | 11 | return res; | 55 | 11 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb0EEEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS8_EE Line | Count | Source | 41 | 11 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 42 | 11 | DataTypePtr res; | 43 | | if constexpr (IsDataTypeDecimalV2<ToDataType>) { | 44 | | res = create_decimal(27, 9, true); | 45 | | if (!res) { | 46 | | throw doris::Exception(ErrorCode::INVALID_ARGUMENT, | 47 | | "Something wrong with create_decimal in function {}", | 48 | | get_name()); | 49 | | __builtin_unreachable(); | 50 | | } | 51 | 11 | } else { | 52 | 11 | res = std::make_shared<ToDataType>(); | 53 | 11 | } | 54 | 11 | return res; | 55 | 11 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb1EEEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS8_EE Line | Count | Source | 41 | 4 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 42 | 4 | DataTypePtr res; | 43 | | if constexpr (IsDataTypeDecimalV2<ToDataType>) { | 44 | | res = create_decimal(27, 9, true); | 45 | | if (!res) { | 46 | | throw doris::Exception(ErrorCode::INVALID_ARGUMENT, | 47 | | "Something wrong with create_decimal in function {}", | 48 | | get_name()); | 49 | | __builtin_unreachable(); | 50 | | } | 51 | 4 | } else { | 52 | 4 | res = std::make_shared<ToDataType>(); | 53 | 4 | } | 54 | 4 | return res; | 55 | 4 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_10XxHashImplILS2_5EEEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS8_EE Line | Count | Source | 41 | 47 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 42 | 47 | DataTypePtr res; | 43 | | if constexpr (IsDataTypeDecimalV2<ToDataType>) { | 44 | | res = create_decimal(27, 9, true); | 45 | | if (!res) { | 46 | | throw doris::Exception(ErrorCode::INVALID_ARGUMENT, | 47 | | "Something wrong with create_decimal in function {}", | 48 | | get_name()); | 49 | | __builtin_unreachable(); | 50 | | } | 51 | 47 | } else { | 52 | 47 | res = std::make_shared<ToDataType>(); | 53 | 47 | } | 54 | 47 | return res; | 55 | 47 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_10XxHashImplILS2_6EEEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS8_EE Line | Count | Source | 41 | 94 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 42 | 94 | DataTypePtr res; | 43 | | if constexpr (IsDataTypeDecimalV2<ToDataType>) { | 44 | | res = create_decimal(27, 9, true); | 45 | | if (!res) { | 46 | | throw doris::Exception(ErrorCode::INVALID_ARGUMENT, | 47 | | "Something wrong with create_decimal in function {}", | 48 | | get_name()); | 49 | | __builtin_unreachable(); | 50 | | } | 51 | 94 | } else { | 52 | 94 | res = std::make_shared<ToDataType>(); | 53 | 94 | } | 54 | 94 | return res; | 55 | 94 | } |
|
56 | | |
57 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
58 | 807 | uint32_t result, size_t input_rows_count) const override { |
59 | 807 | ToDataType to_type; |
60 | 807 | auto column = to_type.create_column(); |
61 | 807 | column->reserve(input_rows_count); |
62 | | |
63 | 807 | if (arguments.empty()) { |
64 | 0 | RETURN_IF_ERROR(Impl::empty_apply(column->assume_mutable_ref(), input_rows_count)); |
65 | 807 | } else { |
66 | 807 | const ColumnWithTypeAndName& first_col = block.get_by_position(arguments[0]); |
67 | 807 | RETURN_IF_ERROR(Impl::first_apply(first_col.type.get(), first_col.column.get(), |
68 | 807 | input_rows_count, column->assume_mutable_ref())); |
69 | | |
70 | 835 | for (size_t i = 1; i < arguments.size(); ++i) { |
71 | 28 | const ColumnWithTypeAndName& col = block.get_by_position(arguments[i]); |
72 | 28 | RETURN_IF_ERROR(Impl::combine_apply(col.type.get(), col.column.get(), |
73 | 28 | input_rows_count, |
74 | 28 | column->assume_mutable_ref())); |
75 | 28 | } |
76 | 807 | } |
77 | | |
78 | 807 | block.get_by_position(result).column = std::move(column); |
79 | 807 | return Status::OK(); |
80 | 807 | } _ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_15MurmurHash3ImplILS2_5ELb0EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 58 | 23 | uint32_t result, size_t input_rows_count) const override { | 59 | 23 | ToDataType to_type; | 60 | 23 | auto column = to_type.create_column(); | 61 | 23 | column->reserve(input_rows_count); | 62 | | | 63 | 23 | if (arguments.empty()) { | 64 | 0 | RETURN_IF_ERROR(Impl::empty_apply(column->assume_mutable_ref(), input_rows_count)); | 65 | 23 | } else { | 66 | 23 | const ColumnWithTypeAndName& first_col = block.get_by_position(arguments[0]); | 67 | 23 | RETURN_IF_ERROR(Impl::first_apply(first_col.type.get(), first_col.column.get(), | 68 | 23 | input_rows_count, column->assume_mutable_ref())); | 69 | | | 70 | 28 | for (size_t i = 1; i < arguments.size(); ++i) { | 71 | 5 | const ColumnWithTypeAndName& col = block.get_by_position(arguments[i]); | 72 | 5 | RETURN_IF_ERROR(Impl::combine_apply(col.type.get(), col.column.get(), | 73 | 5 | input_rows_count, | 74 | 5 | column->assume_mutable_ref())); | 75 | 5 | } | 76 | 23 | } | 77 | | | 78 | 23 | block.get_by_position(result).column = std::move(column); | 79 | 23 | return Status::OK(); | 80 | 23 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb0EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 58 | 23 | uint32_t result, size_t input_rows_count) const override { | 59 | 23 | ToDataType to_type; | 60 | 23 | auto column = to_type.create_column(); | 61 | 23 | column->reserve(input_rows_count); | 62 | | | 63 | 23 | if (arguments.empty()) { | 64 | 0 | RETURN_IF_ERROR(Impl::empty_apply(column->assume_mutable_ref(), input_rows_count)); | 65 | 23 | } else { | 66 | 23 | const ColumnWithTypeAndName& first_col = block.get_by_position(arguments[0]); | 67 | 23 | RETURN_IF_ERROR(Impl::first_apply(first_col.type.get(), first_col.column.get(), | 68 | 23 | input_rows_count, column->assume_mutable_ref())); | 69 | | | 70 | 28 | for (size_t i = 1; i < arguments.size(); ++i) { | 71 | 5 | const ColumnWithTypeAndName& col = block.get_by_position(arguments[i]); | 72 | 5 | RETURN_IF_ERROR(Impl::combine_apply(col.type.get(), col.column.get(), | 73 | 5 | input_rows_count, | 74 | 5 | column->assume_mutable_ref())); | 75 | 5 | } | 76 | 23 | } | 77 | | | 78 | 23 | block.get_by_position(result).column = std::move(column); | 79 | 23 | return Status::OK(); | 80 | 23 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_15MurmurHash3ImplILS2_6ELb1EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 58 | 4 | uint32_t result, size_t input_rows_count) const override { | 59 | 4 | ToDataType to_type; | 60 | 4 | auto column = to_type.create_column(); | 61 | 4 | column->reserve(input_rows_count); | 62 | | | 63 | 4 | if (arguments.empty()) { | 64 | 0 | RETURN_IF_ERROR(Impl::empty_apply(column->assume_mutable_ref(), input_rows_count)); | 65 | 4 | } else { | 66 | 4 | const ColumnWithTypeAndName& first_col = block.get_by_position(arguments[0]); | 67 | 4 | RETURN_IF_ERROR(Impl::first_apply(first_col.type.get(), first_col.column.get(), | 68 | 4 | input_rows_count, column->assume_mutable_ref())); | 69 | | | 70 | 4 | for (size_t i = 1; i < arguments.size(); ++i) { | 71 | 0 | const ColumnWithTypeAndName& col = block.get_by_position(arguments[i]); | 72 | 0 | RETURN_IF_ERROR(Impl::combine_apply(col.type.get(), col.column.get(), | 73 | 0 | input_rows_count, | 74 | 0 | column->assume_mutable_ref())); | 75 | 0 | } | 76 | 4 | } | 77 | | | 78 | 4 | block.get_by_position(result).column = std::move(column); | 79 | 4 | return Status::OK(); | 80 | 4 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_10XxHashImplILS2_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 58 | 104 | uint32_t result, size_t input_rows_count) const override { | 59 | 104 | ToDataType to_type; | 60 | 104 | auto column = to_type.create_column(); | 61 | 104 | column->reserve(input_rows_count); | 62 | | | 63 | 104 | if (arguments.empty()) { | 64 | 0 | RETURN_IF_ERROR(Impl::empty_apply(column->assume_mutable_ref(), input_rows_count)); | 65 | 104 | } else { | 66 | 104 | const ColumnWithTypeAndName& first_col = block.get_by_position(arguments[0]); | 67 | 104 | RETURN_IF_ERROR(Impl::first_apply(first_col.type.get(), first_col.column.get(), | 68 | 104 | input_rows_count, column->assume_mutable_ref())); | 69 | | | 70 | 112 | for (size_t i = 1; i < arguments.size(); ++i) { | 71 | 8 | const ColumnWithTypeAndName& col = block.get_by_position(arguments[i]); | 72 | 8 | RETURN_IF_ERROR(Impl::combine_apply(col.type.get(), col.column.get(), | 73 | 8 | input_rows_count, | 74 | 8 | column->assume_mutable_ref())); | 75 | 8 | } | 76 | 104 | } | 77 | | | 78 | 104 | block.get_by_position(result).column = std::move(column); | 79 | 104 | return Status::OK(); | 80 | 104 | } |
_ZNK5doris29FunctionVariadicArgumentsBaseINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_10XxHashImplILS2_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 58 | 653 | uint32_t result, size_t input_rows_count) const override { | 59 | 653 | ToDataType to_type; | 60 | 653 | auto column = to_type.create_column(); | 61 | 653 | column->reserve(input_rows_count); | 62 | | | 63 | 653 | if (arguments.empty()) { | 64 | 0 | RETURN_IF_ERROR(Impl::empty_apply(column->assume_mutable_ref(), input_rows_count)); | 65 | 653 | } else { | 66 | 653 | const ColumnWithTypeAndName& first_col = block.get_by_position(arguments[0]); | 67 | 653 | RETURN_IF_ERROR(Impl::first_apply(first_col.type.get(), first_col.column.get(), | 68 | 653 | input_rows_count, column->assume_mutable_ref())); | 69 | | | 70 | 663 | for (size_t i = 1; i < arguments.size(); ++i) { | 71 | 10 | const ColumnWithTypeAndName& col = block.get_by_position(arguments[i]); | 72 | 10 | RETURN_IF_ERROR(Impl::combine_apply(col.type.get(), col.column.get(), | 73 | 10 | input_rows_count, | 74 | 10 | column->assume_mutable_ref())); | 75 | 10 | } | 76 | 653 | } | 77 | | | 78 | 653 | block.get_by_position(result).column = std::move(column); | 79 | 653 | return Status::OK(); | 80 | 653 | } |
|
81 | | }; |
82 | | } // namespace doris |