be/src/exprs/function/array/function_array_nary.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 | | |
20 | | #include "core/column/column_array.h" |
21 | | #include "core/data_type/data_type_array.h" |
22 | | #include "core/data_type/data_type_number.h" |
23 | | #include "exprs/function/array/function_array_utils.h" |
24 | | #include "exprs/function/function.h" |
25 | | #include "exprs/function/function_helpers.h" |
26 | | |
27 | | namespace doris { |
28 | | #include "common/compile_check_begin.h" |
29 | | |
30 | | // Functions with more than two arrays of the same element type. |
31 | | template <typename Impl, typename Name> |
32 | | class FunctionArrayNary : public IFunction { |
33 | | public: |
34 | | static constexpr auto name = Name::name; |
35 | 4 | static FunctionPtr create() { return std::make_shared<FunctionArrayNary>(); }_ZN5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE0EEENS_18NameArrayIntersectEE6createEv Line | Count | Source | 35 | 2 | static FunctionPtr create() { return std::make_shared<FunctionArrayNary>(); } |
_ZN5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE1EEENS_14NameArrayUnionEE6createEv Line | Count | Source | 35 | 2 | static FunctionPtr create() { return std::make_shared<FunctionArrayNary>(); } |
|
36 | 0 | String get_name() const override { return name; }Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE0EEENS_18NameArrayIntersectEE8get_nameB5cxx11Ev Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE1EEENS_14NameArrayUnionEE8get_nameB5cxx11Ev |
37 | 2 | bool is_variadic() const override { return true; }_ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE0EEENS_18NameArrayIntersectEE11is_variadicEv Line | Count | Source | 37 | 1 | bool is_variadic() const override { return true; } |
_ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE1EEENS_14NameArrayUnionEE11is_variadicEv Line | Count | Source | 37 | 1 | bool is_variadic() const override { return true; } |
|
38 | 0 | size_t get_number_of_arguments() const override { return 0; }Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE0EEENS_18NameArrayIntersectEE23get_number_of_argumentsEv Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE1EEENS_14NameArrayUnionEE23get_number_of_argumentsEv |
39 | | |
40 | 0 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
41 | 0 | DCHECK(arguments.size() >= 2) |
42 | 0 | << "function: " << get_name() << ", arguments should large equals than 2"; |
43 | 0 | CHECK(arguments[0]->get_primitive_type() == TYPE_ARRAY) |
44 | 0 | << "0-th element is " << arguments[0]->get_name() << ",not array type"; |
45 | 0 | auto nested_type = remove_nullable( |
46 | 0 | assert_cast<const DataTypeArray&>(*(arguments[0])).get_nested_type()); |
47 | 0 | for (size_t i = 1; i < arguments.size(); ++i) { |
48 | 0 | CHECK(arguments[i]->get_primitive_type() == TYPE_ARRAY) |
49 | 0 | << i << "-th element is " << arguments[i]->get_name() << ", not array type"; |
50 | 0 | auto right_nested_type = remove_nullable( |
51 | 0 | assert_cast<const DataTypeArray&>(*(remove_nullable(arguments[i]))) |
52 | 0 | .get_nested_type()); |
53 | | // do check array nested data type, now we just support same nested data type |
54 | 0 | CHECK(nested_type->equals_ignore_precision(*right_nested_type)) |
55 | 0 | << "data type " << arguments[i]->get_name() << " not equal with " |
56 | 0 | << arguments[0]->get_name(); |
57 | 0 | } |
58 | 0 | DataTypePtr res_data_type = Impl::get_return_type(arguments); |
59 | 0 | return res_data_type; |
60 | 0 | } Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE0EEENS_18NameArrayIntersectEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaISA_EE Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE1EEENS_14NameArrayUnionEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaISA_EE |
61 | | |
62 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
63 | 0 | uint32_t result, size_t input_rows_count) const override { |
64 | 0 | ColumnPtr res_ptr; |
65 | 0 | ColumnArrayExecutionDatas datas(arguments.size()); |
66 | 0 | std::vector<bool> col_const(arguments.size()); |
67 | 0 | for (int i = 0; i < arguments.size(); ++i) { |
68 | 0 | const auto& [col, is_const] = |
69 | 0 | unpack_if_const(block.get_by_position(arguments[i]).column); |
70 | 0 | col_const[i] = is_const; |
71 | 0 | extract_column_array_info(*col, datas[i]); |
72 | 0 | } |
73 | 0 | if (Status st = Impl::execute(res_ptr, datas, col_const, 0, input_rows_count); !st.ok()) { |
74 | 0 | return Status::RuntimeError( |
75 | 0 | fmt::format("function {} execute failed {} ", get_name(), st.to_string())); |
76 | 0 | } |
77 | 0 | block.replace_by_position(result, std::move(res_ptr)); |
78 | 0 | return Status::OK(); |
79 | 0 | } Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE0EEENS_18NameArrayIntersectEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Unexecuted instantiation: _ZNK5doris17FunctionArrayNaryINS_12ArrayMapImplILNS_12MapOperationE1EEENS_14NameArrayUnionEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm |
80 | | }; |
81 | | |
82 | | #include "common/compile_check_end.h" |
83 | | } // namespace doris |