be/src/exprs/aggregate/aggregate_function_collect.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/aggregate/aggregate_function_collect.h" |
19 | | |
20 | | #include "exprs/aggregate/aggregate_function_simple_factory.h" |
21 | | #include "exprs/aggregate/factory_helpers.h" |
22 | | #include "exprs/aggregate/helpers.h" |
23 | | |
24 | | namespace doris { |
25 | | #include "common/compile_check_begin.h" |
26 | | |
27 | | // Forward declarations — template instantiations live in separate TUs |
28 | | AggregateFunctionPtr create_aggregate_function_collect_no_limit(const std::string& name, |
29 | | const DataTypes& argument_types, |
30 | | const bool result_is_nullable, |
31 | | const AggregateFunctionAttr& attr); |
32 | | AggregateFunctionPtr create_aggregate_function_collect_with_limit( |
33 | | const std::string& name, const DataTypes& argument_types, const bool result_is_nullable, |
34 | | const AggregateFunctionAttr& attr); |
35 | | |
36 | | AggregateFunctionPtr create_aggregate_function_collect(const std::string& name, |
37 | | const DataTypes& argument_types, |
38 | | const DataTypePtr& result_type, |
39 | | const bool result_is_nullable, |
40 | 2.64k | const AggregateFunctionAttr& attr) { |
41 | 2.64k | assert_arity_range(name, argument_types, 1, 2); |
42 | 2.64k | if (argument_types.size() == 1) { |
43 | 1.37k | return create_aggregate_function_collect_no_limit(name, argument_types, result_is_nullable, |
44 | 1.37k | attr); |
45 | 1.37k | } |
46 | 1.26k | if (argument_types.size() == 2) { |
47 | 1.26k | return create_aggregate_function_collect_with_limit(name, argument_types, |
48 | 1.26k | result_is_nullable, attr); |
49 | 1.26k | } |
50 | 2 | return nullptr; |
51 | 1.26k | } |
52 | | |
53 | 9 | void register_aggregate_function_collect_list(AggregateFunctionSimpleFactory& factory) { |
54 | | // notice: array_agg only differs from collect_list in that array_agg will show null elements in array |
55 | 9 | factory.register_function_both("collect_list", create_aggregate_function_collect); |
56 | 9 | factory.register_function_both("collect_set", create_aggregate_function_collect); |
57 | 9 | factory.register_alias("collect_list", "group_array"); |
58 | 9 | factory.register_alias("collect_set", "group_uniq_array"); |
59 | 9 | } |
60 | | } // namespace doris |