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 | 131 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
46 | 131 | if constexpr (AlwaysNullable) { |
47 | 11 | return make_nullable(std::make_shared<ReturnType>()); |
48 | 11 | } |
49 | 0 | return std::make_shared<ReturnType>(); |
50 | 131 | } _ZN5doris20FunctionFakeBaseImplINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEELb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE Line | Count | Source | 45 | 1 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 46 | | if constexpr (AlwaysNullable) { | 47 | | return make_nullable(std::make_shared<ReturnType>()); | 48 | | } | 49 | 1 | return std::make_shared<ReturnType>(); | 50 | 1 | } |
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 | 80 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 46 | | if constexpr (AlwaysNullable) { | 47 | | return make_nullable(std::make_shared<ReturnType>()); | 48 | | } | 49 | 80 | return std::make_shared<ReturnType>(); | 50 | 80 | } |
_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 | DORIS_CHECK(arguments[0]->get_primitive_type() == TYPE_ARRAY); |
64 | 0 | return make_nullable( |
65 | 0 | check_and_get_data_type<DataTypeArray>(arguments[0].get())->get_nested_type()); |
66 | 0 | } |
67 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
68 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
69 | | }; |
70 | | |
71 | | struct FunctionExplodeV2 { |
72 | 317 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
73 | 317 | DataTypes fieldTypes(arguments.size()); |
74 | 670 | for (int i = 0; i < arguments.size(); i++) { |
75 | 353 | if (arguments[i]->get_primitive_type() == PrimitiveType::TYPE_VARIANT) { |
76 | 20 | if (arguments[i]->is_nullable()) { |
77 | 0 | fieldTypes[i] = arguments[i]; |
78 | 20 | } else { |
79 | 20 | fieldTypes[i] = make_nullable(arguments[i]); |
80 | 20 | } |
81 | 333 | } else { |
82 | 333 | auto nestedType = check_and_get_data_type<DataTypeArray>(arguments[i].get()) |
83 | 333 | ->get_nested_type(); |
84 | 333 | if (nestedType->is_nullable()) { |
85 | 333 | fieldTypes[i] = nestedType; |
86 | 333 | } else { |
87 | 0 | fieldTypes[i] = make_nullable(nestedType); |
88 | 0 | } |
89 | 333 | } |
90 | 353 | } |
91 | | |
92 | 317 | if (fieldTypes.size() > 1) { |
93 | 25 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
94 | 292 | } else { |
95 | 292 | return make_nullable(fieldTypes[0]); |
96 | 292 | } |
97 | 317 | } |
98 | 24 | static DataTypes get_variadic_argument_types() { return {}; } |
99 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
100 | | }; |
101 | | |
102 | | // explode map: make map k,v as struct field |
103 | | struct FunctionExplodeMap { |
104 | 31 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
105 | 31 | DORIS_CHECK(arguments[0]->get_primitive_type() == TYPE_MAP); |
106 | 31 | DataTypes fieldTypes(2); |
107 | 31 | fieldTypes[0] = check_and_get_data_type<DataTypeMap>(arguments[0].get())->get_key_type(); |
108 | 31 | fieldTypes[1] = check_and_get_data_type<DataTypeMap>(arguments[0].get())->get_value_type(); |
109 | 31 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
110 | 31 | } |
111 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
112 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
113 | | }; |
114 | | |
115 | | template <bool AlwaysNullable = false> |
116 | | struct FunctionPoseExplode { |
117 | 73 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
118 | 73 | DataTypes fieldTypes(arguments.size() + 1); |
119 | 73 | fieldTypes[0] = std::make_shared<DataTypeInt32>(); |
120 | 165 | for (int i = 0; i < arguments.size(); i++) { |
121 | 92 | DORIS_CHECK(arguments[i]->get_primitive_type() == TYPE_ARRAY); |
122 | 92 | auto nestedType = |
123 | 92 | check_and_get_data_type<DataTypeArray>(arguments[i].get())->get_nested_type(); |
124 | 92 | fieldTypes[i + 1] = make_nullable(nestedType); |
125 | 92 | } |
126 | 73 | auto struct_type = std::make_shared<DataTypeStruct>(fieldTypes); |
127 | 73 | if constexpr (AlwaysNullable) { |
128 | 23 | return make_nullable(struct_type); |
129 | 50 | } else { |
130 | 50 | return struct_type; |
131 | 50 | } |
132 | 73 | } _ZN5doris19FunctionPoseExplodeILb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 117 | 50 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 118 | 50 | DataTypes fieldTypes(arguments.size() + 1); | 119 | 50 | fieldTypes[0] = std::make_shared<DataTypeInt32>(); | 120 | 111 | for (int i = 0; i < arguments.size(); i++) { | 121 | 61 | DORIS_CHECK(arguments[i]->get_primitive_type() == TYPE_ARRAY); | 122 | 61 | auto nestedType = | 123 | 61 | check_and_get_data_type<DataTypeArray>(arguments[i].get())->get_nested_type(); | 124 | 61 | fieldTypes[i + 1] = make_nullable(nestedType); | 125 | 61 | } | 126 | 50 | auto struct_type = std::make_shared<DataTypeStruct>(fieldTypes); | 127 | | if constexpr (AlwaysNullable) { | 128 | | return make_nullable(struct_type); | 129 | 50 | } else { | 130 | 50 | return struct_type; | 131 | 50 | } | 132 | 50 | } |
_ZN5doris19FunctionPoseExplodeILb1EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 117 | 23 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { | 118 | 23 | DataTypes fieldTypes(arguments.size() + 1); | 119 | 23 | fieldTypes[0] = std::make_shared<DataTypeInt32>(); | 120 | 54 | for (int i = 0; i < arguments.size(); i++) { | 121 | 31 | DORIS_CHECK(arguments[i]->get_primitive_type() == TYPE_ARRAY); | 122 | 31 | auto nestedType = | 123 | 31 | check_and_get_data_type<DataTypeArray>(arguments[i].get())->get_nested_type(); | 124 | 31 | fieldTypes[i + 1] = make_nullable(nestedType); | 125 | 31 | } | 126 | 23 | auto struct_type = std::make_shared<DataTypeStruct>(fieldTypes); | 127 | 23 | if constexpr (AlwaysNullable) { | 128 | 23 | return make_nullable(struct_type); | 129 | | } else { | 130 | | return struct_type; | 131 | | } | 132 | 23 | } |
|
133 | 16 | static DataTypes get_variadic_argument_types() { return {}; }_ZN5doris19FunctionPoseExplodeILb0EE27get_variadic_argument_typesEv Line | Count | Source | 133 | 8 | static DataTypes get_variadic_argument_types() { return {}; } |
_ZN5doris19FunctionPoseExplodeILb1EE27get_variadic_argument_typesEv Line | Count | Source | 133 | 8 | static DataTypes get_variadic_argument_types() { return {}; } |
|
134 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; }Unexecuted instantiation: _ZN5doris19FunctionPoseExplodeILb0EE13get_error_msgB5cxx11Ev Unexecuted instantiation: _ZN5doris19FunctionPoseExplodeILb1EE13get_error_msgB5cxx11Ev |
135 | | }; |
136 | | |
137 | | // explode json-object: expands json-object to struct with a pair of key and value in column string |
138 | | struct FunctionExplodeJsonObject { |
139 | 4 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
140 | 4 | DORIS_CHECK(arguments[0]->get_primitive_type() == PrimitiveType::TYPE_JSONB); |
141 | 4 | DataTypes fieldTypes(2); |
142 | 4 | fieldTypes[0] = make_nullable(std::make_shared<DataTypeString>()); |
143 | 4 | fieldTypes[1] = make_nullable(std::make_shared<DataTypeJsonb>()); |
144 | 4 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
145 | 4 | } |
146 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
147 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
148 | | }; |
149 | | |
150 | | // json_each(json) -> Nullable(Struct(key Nullable(String), value Nullable(JSONB))) |
151 | | struct FunctionJsonEach { |
152 | 27 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
153 | 27 | DORIS_CHECK(arguments[0]->get_primitive_type() == PrimitiveType::TYPE_JSONB); |
154 | 27 | DataTypes fieldTypes(2); |
155 | 27 | fieldTypes[0] = make_nullable(std::make_shared<DataTypeString>()); |
156 | 27 | fieldTypes[1] = make_nullable(std::make_shared<DataTypeJsonb>()); |
157 | 27 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
158 | 27 | } |
159 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
160 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
161 | | }; |
162 | | |
163 | | // json_each_text(json) -> Nullable(Struct(key Nullable(String), value Nullable(String))) |
164 | | struct FunctionJsonEachText { |
165 | 19 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
166 | 19 | DORIS_CHECK(arguments[0]->get_primitive_type() == PrimitiveType::TYPE_JSONB); |
167 | 19 | DataTypes fieldTypes(2); |
168 | 19 | fieldTypes[0] = make_nullable(std::make_shared<DataTypeString>()); |
169 | 19 | fieldTypes[1] = make_nullable(std::make_shared<DataTypeString>()); |
170 | 19 | return make_nullable(std::make_shared<DataTypeStruct>(fieldTypes)); |
171 | 19 | } |
172 | 16 | static DataTypes get_variadic_argument_types() { return {}; } |
173 | 0 | static std::string get_error_msg() { return "Fake function do not support execute"; } |
174 | | }; |
175 | | |
176 | | struct FunctionEsquery { |
177 | 1 | static DataTypePtr get_return_type_impl(const DataTypes& arguments) { |
178 | 1 | return FunctionFakeBaseImpl<DataTypeUInt8>::get_return_type_impl(arguments); |
179 | 1 | } |
180 | 8 | static DataTypes get_variadic_argument_types() { return {}; } |
181 | 0 | static std::string get_error_msg() { return "esquery only supported on es table"; } |
182 | | }; |
183 | | |
184 | | template <typename FunctionImpl> |
185 | 8 | void register_function(SimpleFunctionFactory& factory, const std::string& name) { |
186 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); |
187 | 8 | }; |
188 | | |
189 | | template <typename FunctionImpl> |
190 | | void register_table_function_expand(SimpleFunctionFactory& factory, const std::string& name, |
191 | 40 | const std::string& suffix) { |
192 | 40 | factory.register_function<FunctionFake<FunctionImpl>>(name); |
193 | 40 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); |
194 | 40 | }; _ZN5doris30register_table_function_expandINS_17FunctionExplodeV2EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 191 | 8 | const std::string& suffix) { | 192 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 193 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 194 | 8 | }; |
_ZN5doris30register_table_function_expandINS_18FunctionExplodeMapEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 191 | 8 | const std::string& suffix) { | 192 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 193 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 194 | 8 | }; |
_ZN5doris30register_table_function_expandINS_25FunctionExplodeJsonObjectEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 191 | 8 | const std::string& suffix) { | 192 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 193 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 194 | 8 | }; |
_ZN5doris30register_table_function_expandINS_16FunctionJsonEachEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 191 | 8 | const std::string& suffix) { | 192 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 193 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 194 | 8 | }; |
_ZN5doris30register_table_function_expandINS_20FunctionJsonEachTextEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 191 | 8 | const std::string& suffix) { | 192 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name); | 193 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 194 | 8 | }; |
|
195 | | |
196 | | template <typename FunctionImpl> |
197 | | void register_table_alternative_function_expand(SimpleFunctionFactory& factory, |
198 | | const std::string& name, |
199 | 8 | const std::string& suffix) { |
200 | 8 | factory.register_alternative_function<FunctionFake<FunctionImpl>>(name); |
201 | 8 | factory.register_alternative_function<FunctionFake<FunctionImpl>>(name + suffix); |
202 | 8 | }; |
203 | | |
204 | | template <typename ReturnType, bool VARIADIC> |
205 | | void register_table_function_expand_default(SimpleFunctionFactory& factory, const std::string& name, |
206 | 64 | const std::string& suffix) { |
207 | 64 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( |
208 | 64 | name); |
209 | 64 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( |
210 | 64 | name + suffix); |
211 | 64 | }; _ZN5doris38register_table_function_expand_defaultINS_14DataTypeStringELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 206 | 16 | const std::string& suffix) { | 207 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 208 | 16 | name); | 209 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 210 | 16 | name + suffix); | 211 | 16 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_ Line | Count | Source | 206 | 8 | const std::string& suffix) { | 207 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 208 | 8 | name); | 209 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 210 | 8 | name + suffix); | 211 | 8 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_ Line | Count | Source | 206 | 16 | const std::string& suffix) { | 207 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 208 | 16 | name); | 209 | 16 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 210 | 16 | name + suffix); | 211 | 16 | }; |
_ZN5doris38register_table_function_expand_defaultINS_13DataTypeJsonbELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 206 | 8 | const std::string& suffix) { | 207 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 208 | 8 | name); | 209 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 210 | 8 | name + suffix); | 211 | 8 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeStringELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 206 | 8 | const std::string& suffix) { | 207 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 208 | 8 | name); | 209 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 210 | 8 | name + suffix); | 211 | 8 | }; |
_ZN5doris38register_table_function_expand_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_ Line | Count | Source | 206 | 8 | const std::string& suffix) { | 207 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>( | 208 | 8 | name); | 209 | 8 | factory.register_function<FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>( | 210 | 8 | name + suffix); | 211 | 8 | }; |
|
212 | | |
213 | | template <typename ReturnType, bool VARIADIC> |
214 | | void register_table_alternative_function_expand_default(SimpleFunctionFactory& factory, |
215 | | const std::string& name, |
216 | 8 | const std::string& suffix) { |
217 | 8 | factory.register_alternative_function< |
218 | 8 | FunctionFake<FunctionFakeBaseImpl<ReturnType, false, VARIADIC>>>(name); |
219 | 8 | factory.register_alternative_function< |
220 | 8 | FunctionFake<FunctionFakeBaseImpl<ReturnType, true, VARIADIC>>>(name + suffix); |
221 | 8 | }; |
222 | | |
223 | | template <typename FunctionImpl> |
224 | 40 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { |
225 | 40 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); |
226 | 40 | }; _ZN5doris36register_table_function_expand_outerINS_17FunctionExplodeV2EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 224 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 225 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 226 | 8 | }; |
_ZN5doris36register_table_function_expand_outerINS_18FunctionExplodeMapEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 224 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 225 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 226 | 8 | }; |
_ZN5doris36register_table_function_expand_outerINS_25FunctionExplodeJsonObjectEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 224 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 225 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 226 | 8 | }; |
_ZN5doris36register_table_function_expand_outerINS_16FunctionJsonEachEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 224 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 225 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 226 | 8 | }; |
_ZN5doris36register_table_function_expand_outerINS_20FunctionJsonEachTextEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 224 | 8 | void register_table_function_expand_outer(SimpleFunctionFactory& factory, const std::string& name) { | 225 | 8 | register_table_function_expand<FunctionImpl>(factory, name, COMBINATOR_SUFFIX_OUTER); | 226 | 8 | }; |
|
227 | | |
228 | | template <typename FunctionImpl> |
229 | | void register_table_alternative_function_expand_outer(SimpleFunctionFactory& factory, |
230 | 8 | const std::string& name) { |
231 | 8 | register_table_alternative_function_expand<FunctionImpl>(factory, name, |
232 | 8 | COMBINATOR_SUFFIX_OUTER); |
233 | 8 | }; |
234 | | |
235 | | template <typename ReturnType, bool VARIADIC> |
236 | | void register_table_function_expand_outer_default(SimpleFunctionFactory& factory, |
237 | 64 | const std::string& name) { |
238 | 64 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, |
239 | 64 | COMBINATOR_SUFFIX_OUTER); |
240 | 64 | }; _ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeStringELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 237 | 16 | const std::string& name) { | 238 | 16 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 239 | 16 | COMBINATOR_SUFFIX_OUTER); | 240 | 16 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 237 | 8 | const std::string& name) { | 238 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 239 | 8 | COMBINATOR_SUFFIX_OUTER); | 240 | 8 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 237 | 16 | const std::string& name) { | 238 | 16 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 239 | 16 | COMBINATOR_SUFFIX_OUTER); | 240 | 16 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_13DataTypeJsonbELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 237 | 8 | const std::string& name) { | 238 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 239 | 8 | COMBINATOR_SUFFIX_OUTER); | 240 | 8 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeStringELb1EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 237 | 8 | const std::string& name) { | 238 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 239 | 8 | COMBINATOR_SUFFIX_OUTER); | 240 | 8 | }; |
_ZN5doris44register_table_function_expand_outer_defaultINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEELb0EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Line | Count | Source | 237 | 8 | const std::string& name) { | 238 | 8 | register_table_function_expand_default<ReturnType, VARIADIC>(factory, name, | 239 | 8 | COMBINATOR_SUFFIX_OUTER); | 240 | 8 | }; |
|
241 | | |
242 | | template <typename ReturnType, bool VARIADIC> |
243 | | void register_table_alternative_function_expand_outer_default(SimpleFunctionFactory& factory, |
244 | 8 | const std::string& name) { |
245 | 8 | register_table_alternative_function_expand_default<ReturnType, VARIADIC>( |
246 | 8 | factory, name, COMBINATOR_SUFFIX_OUTER); |
247 | 8 | }; |
248 | | |
249 | | template <typename FunctionImpl> |
250 | | void register_table_function_with_impl(SimpleFunctionFactory& factory, const std::string& name, |
251 | 24 | const std::string& suffix = "") { |
252 | 24 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); |
253 | 24 | }; _ZN5doris33register_table_function_with_implINS_19FunctionPoseExplodeILb0EEEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESC_ Line | Count | Source | 251 | 8 | const std::string& suffix = "") { | 252 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 253 | 8 | }; |
_ZN5doris33register_table_function_with_implINS_19FunctionPoseExplodeILb1EEEEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESC_ Line | Count | Source | 251 | 8 | const std::string& suffix = "") { | 252 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 253 | 8 | }; |
_ZN5doris33register_table_function_with_implINS_17FunctionExplodeV2EEEvRNS_21SimpleFunctionFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_ Line | Count | Source | 251 | 8 | const std::string& suffix = "") { | 252 | 8 | factory.register_function<FunctionFake<FunctionImpl>>(name + suffix); | 253 | 8 | }; |
|
254 | | |
255 | 8 | void register_function_fake(SimpleFunctionFactory& factory) { |
256 | 8 | register_function<FunctionEsquery>(factory, "esquery"); |
257 | | |
258 | 8 | register_table_function_expand_outer<FunctionExplodeV2>(factory, "explode"); |
259 | 8 | register_table_alternative_function_expand_outer<FunctionExplode>(factory, "explode"); |
260 | | |
261 | 8 | register_table_function_expand_outer<FunctionExplodeMap>(factory, "explode_map"); |
262 | | |
263 | 8 | register_table_function_expand_outer<FunctionExplodeJsonObject>(factory, "explode_json_object"); |
264 | 8 | register_table_function_expand_outer<FunctionJsonEach>(factory, "json_each"); |
265 | 8 | register_table_function_expand_outer<FunctionJsonEachText>(factory, "json_each_text"); |
266 | 8 | register_table_function_expand_outer_default<DataTypeString, false>(factory, "explode_split"); |
267 | 8 | register_table_function_expand_outer_default<DataTypeInt32, false>(factory, "explode_numbers"); |
268 | 8 | register_table_function_expand_outer_default<DataTypeInt64, false>(factory, |
269 | 8 | "explode_json_array_int"); |
270 | 8 | register_table_function_expand_outer_default<DataTypeString, false>( |
271 | 8 | factory, "explode_json_array_string"); |
272 | 8 | register_table_function_expand_outer_default<DataTypeJsonb, true>(factory, |
273 | 8 | "explode_json_array_json"); |
274 | 8 | register_table_function_expand_outer_default<DataTypeString, true>(factory, |
275 | 8 | "explode_json_array_json"); |
276 | 8 | register_table_function_expand_outer_default<DataTypeFloat64, false>( |
277 | 8 | factory, "explode_json_array_double"); |
278 | 8 | register_table_function_expand_outer_default<DataTypeInt64, false>(factory, "explode_bitmap"); |
279 | 8 | register_table_function_with_impl<FunctionPoseExplode<false>>(factory, "posexplode"); |
280 | 8 | register_table_function_with_impl<FunctionPoseExplode<true>>(factory, "posexplode", |
281 | 8 | COMBINATOR_SUFFIX_OUTER); |
282 | 8 | register_table_alternative_function_expand_outer_default<DataTypeVariant, false>( |
283 | 8 | factory, "explode_variant_array"); |
284 | 8 | register_table_function_with_impl<FunctionExplodeV2>(factory, "explode_variant_array"); |
285 | 8 | } |
286 | | |
287 | | } // namespace doris |