be/src/exprs/function/function_fake.cpp
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 | | #include "exprs/function/function_fake.h" |
19 | | |
20 | | #include <glog/logging.h> |
21 | | |
22 | | #include <algorithm> |
23 | | #include <boost/iterator/iterator_facade.hpp> |
24 | | #include <memory> |
25 | | #include <ostream> |
26 | | #include <string> |
27 | | |
28 | | #include "core/data_type/data_type_array.h" |
29 | | #include "core/data_type/data_type_jsonb.h" |
30 | | #include "core/data_type/data_type_map.h" |
31 | | #include "core/data_type/data_type_nullable.h" |
32 | | #include "core/data_type/data_type_number.h" |
33 | | #include "core/data_type/data_type_string.h" |
34 | | #include "core/data_type/data_type_struct.h" |
35 | | #include "core/data_type/data_type_variant.h" |
36 | | #include "exprs/aggregate/aggregate_function.h" |
37 | | #include "exprs/function/function_helpers.h" |
38 | | #include "exprs/function/simple_function_factory.h" |
39 | | #include "exprs/table_function/table_function.h" |
40 | | |
41 | | namespace doris { |
42 | | |
43 | | template <typename ReturnType, bool AlwaysNullable = false, bool VARIADIC = false> |
44 | | struct FunctionFakeBaseImpl { |
45 | 129 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
46 | 129 | if constexpr (AlwaysNullable) { |
47 | 11 | return make_nullable(std::make_shared<ReturnType>()); |
48 | 11 | } |
49 | 0 | return std::make_shared<ReturnType>(); |
50 | 129 | } Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEELb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb1ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 45 | 79 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 46 | | if constexpr (AlwaysNullable) { | 47 | | return make_nullable(std::make_shared<ReturnType>()); | 48 | | } | 49 | 79 | return std::make_shared<ReturnType>(); | 50 | 79 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb1ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 45 | 3 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 46 | 3 | if constexpr (AlwaysNullable) { | 47 | 3 | return make_nullable(std::make_shared<ReturnType>()); | 48 | 3 | } | 49 | 0 | return std::make_shared<ReturnType>(); | 50 | 3 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 45 | 39 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 46 | | if constexpr (AlwaysNullable) { | 47 | | return make_nullable(std::make_shared<ReturnType>()); | 48 | | } | 49 | 39 | return std::make_shared<ReturnType>(); | 50 | 39 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb1ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 45 | 8 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 46 | 8 | if constexpr (AlwaysNullable) { | 47 | 8 | return make_nullable(std::make_shared<ReturnType>()); | 48 | 8 | } | 49 | 0 | return std::make_shared<ReturnType>(); | 50 | 8 | } |
Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_13DataTypeJsonbELb0ELb1EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_13DataTypeJsonbELb1ELb1EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb0ELb1EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb1ELb1EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb1ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_15DataTypeVariantELb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_15DataTypeVariantELb1ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE |
51 | 144 | static DataTypes get_variadic_argument_types() { |
52 | 144 | if constexpr (VARIADIC) { |
53 | 32 | return {std::make_shared<ReturnType>()}; |
54 | 112 | } else { |
55 | 112 | return {}; |
56 | 112 | } |
57 | 144 | } _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb0ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 16 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 16 | } else { | 55 | 16 | return {}; | 56 | 16 | } | 57 | 16 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb1ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 16 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 16 | } else { | 55 | 16 | return {}; | 56 | 16 | } | 57 | 16 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb0ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 8 | } else { | 55 | 8 | return {}; | 56 | 8 | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb1ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 8 | } else { | 55 | 8 | return {}; | 56 | 8 | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb0ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 16 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 16 | } else { | 55 | 16 | return {}; | 56 | 16 | } | 57 | 16 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb1ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 16 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 16 | } else { | 55 | 16 | return {}; | 56 | 16 | } | 57 | 16 | } |
_ZN5doris20FunctionFakeBaseImplINS_13DataTypeJsonbELb0ELb1EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | 8 | if constexpr (VARIADIC) { | 53 | 8 | return {std::make_shared<ReturnType>()}; | 54 | | } else { | 55 | | return {}; | 56 | | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_13DataTypeJsonbELb1ELb1EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | 8 | if constexpr (VARIADIC) { | 53 | 8 | return {std::make_shared<ReturnType>()}; | 54 | | } else { | 55 | | return {}; | 56 | | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb0ELb1EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | 8 | if constexpr (VARIADIC) { | 53 | 8 | return {std::make_shared<ReturnType>()}; | 54 | | } else { | 55 | | return {}; | 56 | | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb1ELb1EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | 8 | if constexpr (VARIADIC) { | 53 | 8 | return {std::make_shared<ReturnType>()}; | 54 | | } else { | 55 | | return {}; | 56 | | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb0ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 8 | } else { | 55 | 8 | return {}; | 56 | 8 | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb1ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 8 | } else { | 55 | 8 | return {}; | 56 | 8 | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_15DataTypeVariantELb0ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 8 | } else { | 55 | 8 | return {}; | 56 | 8 | } | 57 | 8 | } |
_ZN5doris20FunctionFakeBaseImplINS_15DataTypeVariantELb1ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 51 | 8 | static DataTypes get_variadic_argument_types() { | 52 | | if constexpr (VARIADIC) { | 53 | | return {std::make_shared<ReturnType>()}; | 54 | 8 | } else { | 55 | 8 | return {}; | 56 | 8 | } | 57 | 8 | } |
|
58 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; }Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb0ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb1ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb0ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb1ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb0ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb1ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_13DataTypeJsonbELb0ELb1EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_13DataTypeJsonbELb1ELb1EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb0ELb1EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeStringELb1ELb1EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb0ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb1ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_15DataTypeVariantELb0ELb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris20FunctionFakeBaseImplINS_15DataTypeVariantELb1ELb0EE13get_error_msgB5cxx11Ev |
59 | | }; |
60 | | |
61 | | struct FunctionExplode { |
62 | 0 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
63 | 0 | DCHECK(arguments[0]->get_primitive_type() == TYPE_ARRAY) |
64 | 0 | << arguments[0]->get_name() << " not supported"; |
65 | 0 | return make_nullable( |
66 | 0 | check_and_get_data_type<DataTypeArray>(arguments[0].get())->get_nested_type()); |
67 | 0 | } |
68 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
69 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
70 | | }; |
71 | | |
72 | | struct FunctionExplodeV2 { |
73 | 313 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
74 | 313 | DataTypes fieldTypes(arguments.size()); |
75 | 662 | for (int i = 0; i < arguments.size(); i++) { |
76 | 349 | if (arguments[i]->get_primitive_type() == PrimitiveType::TYPE_VARIANT) { |
77 | 20 | if (arguments[i]->is_nullable()) { |
78 | 0 | fieldTypes[i] = arguments[i]; |
79 | 20 | } else { |
80 | 20 | fieldTypes[i] = make_nullable(arguments[i]); |
81 | 20 | } |
82 | 329 | } else { |
83 | 329 | auto nestedType = check_and_get_data_type<DataTypeArray>(arguments[i].get()) |
84 | 329 | ->get_nested_type(); |
85 | 329 | if (nestedType->is_nullable()) { |
86 | 329 | fieldTypes[i] = nestedType; |
87 | 329 | } else { |
88 | 0 | fieldTypes[i] = make_nullable(nestedType); |
89 | 0 | } |
90 | 329 | } |
91 | 349 | } |
92 | | |
93 | 313 | if (fieldTypes.size() > 1) { |
94 | 25 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
95 | 288 | } else { |
96 | 288 | return make_nullable(fieldTypes[0]); |
97 | 288 | } |
98 | 313 | } |
99 | 24 | static DataTypes get_variadic_argument_types() { return {}; } |
100 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
101 | | }; |
102 | | |
103 | | // explode map: make map k,v as struct field |
104 | | struct FunctionExplodeMap { |
105 | 31 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
106 | 31 | DCHECK(arguments[0]->get_primitive_type() == TYPE_MAP) |
107 | 0 | << arguments[0]->get_name() << " not supported"; |
108 | 31 | DataTypes fieldTypes(2); |
109 | 31 | fieldTypes[0] = check_and_get_data_type<DataTypeMap>(arguments[0].get())->get_key_type(); |
110 | 31 | fieldTypes[1] = check_and_get_data_type<DataTypeMap>(arguments[0].get())->get_value_type(); |
111 | 31 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
112 | 31 | } |
113 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
114 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
115 | | }; |
116 | | |
117 | | template <bool AlwaysNullable = false> |
118 | | struct FunctionPoseExplode { |
119 | 73 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
120 | 73 | DataTypes fieldTypes(arguments.size() + 1); |
121 | 73 | fieldTypes[0] = std::make_shared<DataTypeInt32>(); |
122 | 165 | for (int i = 0; i < arguments.size(); i++) { |
123 | 92 | DCHECK_EQ(arguments[i]->get_primitive_type(), TYPE_ARRAY) |
124 | 0 | << arguments[i]->get_name() << " not supported"; |
125 | 92 | auto nestedType = |
126 | 92 | check_and_get_data_type<DataTypeArray>(arguments[i].get())->get_nested_type(); |
127 | 92 | fieldTypes[i + 1] = make_nullable(nestedType); |
128 | 92 | } |
129 | 73 | auto struct_type = std::make_shared<DataTypeStruct>(fieldTypes); |
130 | 73 | if constexpr (AlwaysNullable) { |
131 | 23 | return make_nullable(struct_type); |
132 | 50 | } else { |
133 | 50 | return struct_type; |
134 | 50 | } |
135 | 73 | } _ZN5doris19FunctionPoseExplodeILb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 119 | 50 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 120 | 50 | DataTypes fieldTypes(arguments.size() + 1); | 121 | 50 | fieldTypes[0] = std::make_shared<DataTypeInt32>(); | 122 | 111 | for (int i = 0; i < arguments.size(); i++) { | 123 | 61 | DCHECK_EQ(arguments[i]->get_primitive_type(), TYPE_ARRAY) | 124 | 0 | << arguments[i]->get_name() << " not supported"; | 125 | 61 | auto nestedType = | 126 | 61 | check_and_get_data_type<DataTypeArray>(arguments[i].get())->get_nested_type(); | 127 | 61 | fieldTypes[i + 1] = make_nullable(nestedType); | 128 | 61 | } | 129 | 50 | auto struct_type = std::make_shared<DataTypeStruct>(fieldTypes); | 130 | | if constexpr (AlwaysNullable) { | 131 | | return make_nullable(struct_type); | 132 | 50 | } else { | 133 | 50 | return struct_type; | 134 | 50 | } | 135 | 50 | } |
_ZN5doris19FunctionPoseExplodeILb1EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 119 | 23 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 120 | 23 | DataTypes fieldTypes(arguments.size() + 1); | 121 | 23 | fieldTypes[0] = std::make_shared<DataTypeInt32>(); | 122 | 54 | for (int i = 0; i < arguments.size(); i++) { | 123 | 31 | DCHECK_EQ(arguments[i]->get_primitive_type(), TYPE_ARRAY) | 124 | 0 | << arguments[i]->get_name() << " not supported"; | 125 | 31 | auto nestedType = | 126 | 31 | check_and_get_data_type<DataTypeArray>(arguments[i].get())->get_nested_type(); | 127 | 31 | fieldTypes[i + 1] = make_nullable(nestedType); | 128 | 31 | } | 129 | 23 | auto struct_type = std::make_shared<DataTypeStruct>(fieldTypes); | 130 | 23 | if constexpr (AlwaysNullable) { | 131 | 23 | return make_nullable(struct_type); | 132 | | } else { | 133 | | return struct_type; | 134 | | } | 135 | 23 | } |
|
136 | 16 | static DataTypes get_variadic_argument_types() { return {}; }_ZN5doris19FunctionPoseExplodeILb0EE27get_variadic_argument_typesEv Line | Count | Source | 136 | 8 | static DataTypes get_variadic_argument_types() { return {}; } |
_ZN5doris19FunctionPoseExplodeILb1EE27get_variadic_argument_typesEv Line | Count | Source | 136 | 8 | static DataTypes get_variadic_argument_types() { return {}; } |
|
137 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; }Unexecuted instantiation: _ZN5doris19FunctionPoseExplodeILb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris19FunctionPoseExplodeILb1EE13get_error_msgB5cxx11Ev |
138 | | }; |
139 | | |
140 | | // explode json-object: expands json-object to struct with a pair of key and value in column string |
141 | | struct FunctionExplodeJsonObject { |
142 | 4 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
143 | 4 | DCHECK_EQ(arguments[0]->get_primitive_type(), PrimitiveType::TYPE_JSONB) |
144 | 0 | << " explode json object " << arguments[0]->get_name() << " not supported"; |
145 | 4 | DataTypes fieldTypes(2); |
146 | 4 | fieldTypes[0] = make_nullable(std::make_shared<DataTypeString>()); |
147 | 4 | fieldTypes[1] = make_nullable(std::make_shared<DataTypeJsonb>()); |
148 | 4 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
149 | 4 | } |
150 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
151 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
152 | | }; |
153 | | |
154 | | struct FunctionEsquery { |
155 | 0 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
156 | 0 | return FunctionFakeBaseImpl<DataTypeUInt8>::get_return_type_impl(arguments); |
157 | 0 | } |
158 | 8 | static DataTypes get_variadic_argument_types() { return {}; } |
159 | 0 | static std::string get_error_msg() { return "esquery only supported on es table"; } |
160 | | }; |
161 | | |
162 | | template <typename FunctionImpl> |
163 | 8 | void register_function(SimpleFunctionFactory& factory, const std::string& name) { |
164 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); |
165 | 8 | }; |
166 | | |
167 | | template <typename FunctionImpl> |
168 | | void register_table_function_expand(SimpleFunctionFactory& factory, const std::string& name, |
169 | 24 | const std::string& suffix) { |
170 | 24 | factory.register_function<FunctionFake<FunctionImpl>>(name); |
171 | 24 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); |
172 | 24 | }; _ZN5doris30register_table_function_expandINS_17FunctionExplodeV2EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 169 | 8 | const std::string& suffix) { | 170 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 171 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 172 | 8 | }; |
_ZN5doris30register_table_function_expandINS_18FunctionExplodeMapEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 169 | 8 | const std::string& suffix) { | 170 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 171 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 172 | 8 | }; |
_ZN5doris30register_table_function_expandINS_25FunctionExplodeJsonObjectEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 169 | 8 | const std::string& suffix) { | 170 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 171 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 172 | 8 | }; |
|
173 | | |
174 | | template <typename FunctionImpl> |
175 | | void register_table_alternative_function_expand(SimpleFunctionFactory& factory, |
176 | | const std::string& name, |
177 | 8 | const std::string& suffix) { |
178 | 8 | factory.register_alternative_function<FunctionFake<FunctionImpl>>(name); |
179 | 8 | factory.register_alternative_function<FunctionFake<FunctionImpl>>(name + suffix); |
180 | 8 | }; |
181 | | |
182 | | template <typename ReturnType, bool VARIADIC> |
183 | | void register_table_function_expand_default(SimpleFunctionFactory& factory, const std::string& name, |
184 | 64 | const std::string& suffix) { |
185 | 64 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( |
186 | 64 | name); |
187 | 64 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( |
188 | 64 | name + suffix); |
189 | 64 | }; _ZN5doris38register_table_function_expand_defaultINS_14DataTypeStringELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 184 | 16 | const std::string& suffix) { | 185 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 186 | 16 | name); | 187 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 188 | 16 | name + suffix); | 189 | 16 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_ Line | Count | Source | 184 | 8 | const std::string& suffix) { | 185 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 186 | 8 | name); | 187 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 188 | 8 | name + suffix); | 189 | 8 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_ Line | Count | Source | 184 | 16 | const std::string& suffix) { | 185 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 186 | 16 | name); | 187 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 188 | 16 | name + suffix); | 189 | 16 | }; |
_ZN5doris38register_table_function_expand_defaultINS_13DataTypeJsonbELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 184 | 8 | const std::string& suffix) { | 185 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 186 | 8 | name); | 187 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 188 | 8 | name + suffix); | 189 | 8 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeStringELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 184 | 8 | const std::string& suffix) { | 185 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 186 | 8 | name); | 187 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 188 | 8 | name + suffix); | 189 | 8 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_ Line | Count | Source | 184 | 8 | const std::string& suffix) { | 185 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 186 | 8 | name); | 187 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 188 | 8 | name + suffix); | 189 | 8 | }; |
|
190 | | |
191 | | template <typename ReturnType, bool VARIADIC> |
192 | | void register_table_alternative_function_expand_default(SimpleFunctionFactory& factory, |
193 | | const std::string& name, |
194 | 8 | const std::string& suffix) { |
195 | 8 | factory.register_alternative_function< |
196 | 8 | FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>(name); |
197 | 8 | factory.register_alternative_function< |
198 | 8 | FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>(name + suffix); |
199 | 8 | }; |
200 | | |
201 | | template <typename FunctionImpl> |
202 | 24 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { |
203 | 24 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); |
204 | 24 | }; _ZN5doris36register_table_function_expand_outerINS_17FunctionExplodeV2EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 202 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 203 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 204 | 8 | }; |
_ZN5doris36register_table_function_expand_outerINS_18FunctionExplodeMapEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 202 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 203 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 204 | 8 | }; |
_ZN5doris36register_table_function_expand_outerINS_25FunctionExplodeJsonObjectEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 202 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 203 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 204 | 8 | }; |
|
205 | | |
206 | | template <typename FunctionImpl> |
207 | | void register_table_alternative_function_expand_outer(SimpleFunctionFactory& factory, |
208 | 8 | const std::string& name) { |
209 | 8 | register_table_alternative_function_expand<FunctionImpl>(factory, name, |
210 | 8 | COMBINATOR_SUFFIX_OUTER); |
211 | 8 | }; |
212 | | |
213 | | template <typename ReturnType, bool VARIADIC> |
214 | | void register_table_function_expand_outer_default(SimpleFunctionFactory& factory, |
215 | 64 | const std::string& name) { |
216 | 64 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, |
217 | 64 | COMBINATOR_SUFFIX_OUTER); |
218 | 64 | }; _ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeStringELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 215 | 16 | const std::string& name) { | 216 | 16 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 217 | 16 | COMBINATOR_SUFFIX_OUTER); | 218 | 16 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 215 | 8 | const std::string& name) { | 216 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 217 | 8 | COMBINATOR_SUFFIX_OUTER); | 218 | 8 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 215 | 16 | const std::string& name) { | 216 | 16 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 217 | 16 | COMBINATOR_SUFFIX_OUTER); | 218 | 16 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_13DataTypeJsonbELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 215 | 8 | const std::string& name) { | 216 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 217 | 8 | COMBINATOR_SUFFIX_OUTER); | 218 | 8 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeStringELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 215 | 8 | const std::string& name) { | 216 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 217 | 8 | COMBINATOR_SUFFIX_OUTER); | 218 | 8 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 215 | 8 | const std::string& name) { | 216 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 217 | 8 | COMBINATOR_SUFFIX_OUTER); | 218 | 8 | }; |
|
219 | | |
220 | | template <typename ReturnType, bool VARIADIC> |
221 | | void register_table_alternative_function_expand_outer_default(SimpleFunctionFactory& factory, |
222 | 8 | const std::string& name) { |
223 | 8 | register_table_alternative_function_expand_default<ReturnType, VARIADIC>( |
224 | 8 | factory, name, COMBINATOR_SUFFIX_OUTER); |
225 | 8 | }; |
226 | | |
227 | | template <typename FunctionImpl> |
228 | | void register_table_function_with_impl(SimpleFunctionFactory& factory, const std::string& name, |
229 | 24 | const std::string& suffix = "") { |
230 | 24 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); |
231 | 24 | }; _ZN5doris33register_table_function_with_implINS_19FunctionPoseExplodeILb0EEEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESC_ Line | Count | Source | 229 | 8 | const std::string& suffix = "") { | 230 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 231 | 8 | }; |
_ZN5doris33register_table_function_with_implINS_19FunctionPoseExplodeILb1EEEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESC_ Line | Count | Source | 229 | 8 | const std::string& suffix = "") { | 230 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 231 | 8 | }; |
_ZN5doris33register_table_function_with_implINS_17FunctionExplodeV2EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 229 | 8 | const std::string& suffix = "") { | 230 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 231 | 8 | }; |
|
232 | | |
233 | 8 | void register_function_fake(SimpleFunctionFactory& factory) { |
234 | 8 | register_function<FunctionEsquery>(factory, "esquery"); |
235 | | |
236 | 8 | register_table_function_expand_outer<FunctionExplodeV2>(factory, "explode"); |
237 | 8 | register_table_alternative_function_expand_outer<FunctionExplode>(factory, "explode"); |
238 | | |
239 | 8 | register_table_function_expand_outer<FunctionExplodeMap>(factory, "explode_map"); |
240 | | |
241 | 8 | register_table_function_expand_outer<FunctionExplodeJsonObject>(factory, "explode_json_object"); |
242 | 8 | register_table_function_expand_outer_default<DataTypeString, false>(factory, "explode_split"); |
243 | 8 | register_table_function_expand_outer_default<DataTypeInt32, false>(factory, "explode_numbers"); |
244 | 8 | register_table_function_expand_outer_default<DataTypeInt64, false>(factory, |
245 | 8 | "explode_json_array_int"); |
246 | 8 | register_table_function_expand_outer_default<DataTypeString, false>( |
247 | 8 | factory, "explode_json_array_string"); |
248 | 8 | register_table_function_expand_outer_default<DataTypeJsonb, true>(factory, |
249 | 8 | "explode_json_array_json"); |
250 | 8 | register_table_function_expand_outer_default<DataTypeString, true>(factory, |
251 | 8 | "explode_json_array_json"); |
252 | 8 | register_table_function_expand_outer_default<DataTypeFloat64, false>( |
253 | 8 | factory, "explode_json_array_double"); |
254 | 8 | register_table_function_expand_outer_default<DataTypeInt64, false>(factory, "explode_bitmap"); |
255 | 8 | register_table_function_with_impl<FunctionPoseExplode<false>>(factory, "posexplode"); |
256 | 8 | register_table_function_with_impl<FunctionPoseExplode<true>>(factory, "posexplode", |
257 | 8 | COMBINATOR_SUFFIX_OUTER); |
258 | 8 | register_table_alternative_function_expand_outer_default<DataTypeVariant, false>( |
259 | 8 | factory, "explode_variant_array"); |
260 | 8 | register_table_function_with_impl<FunctionExplodeV2>(factory, "explode_variant_array"); |
261 | 8 | } |
262 | | |
263 | | } // namespace doris |