Coverage Report

Created: 2026-04-13 03:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
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
26
// Forward declarations — template instantiations live in separate TUs
27
AggregateFunctionPtr create_aggregate_function_collect_no_limit(const std::string& name,
28
                                                                const DataTypes& argument_types,
29
                                                                const bool result_is_nullable,
30
                                                                const AggregateFunctionAttr& attr);
31
AggregateFunctionPtr create_aggregate_function_collect_with_limit(
32
        const std::string& name, const DataTypes& argument_types, const bool result_is_nullable,
33
        const AggregateFunctionAttr& attr);
34
35
AggregateFunctionPtr create_aggregate_function_collect(const std::string& name,
36
                                                       const DataTypes& argument_types,
37
                                                       const DataTypePtr& result_type,
38
                                                       const bool result_is_nullable,
39
2.71k
                                                       const AggregateFunctionAttr& attr) {
40
2.71k
    assert_arity_range(name, argument_types, 1, 2);
41
2.71k
    if (argument_types.size() == 1) {
42
1.38k
        return create_aggregate_function_collect_no_limit(name, argument_types, result_is_nullable,
43
1.38k
                                                          attr);
44
1.38k
    }
45
1.32k
    if (argument_types.size() == 2) {
46
1.32k
        return create_aggregate_function_collect_with_limit(name, argument_types,
47
1.32k
                                                            result_is_nullable, attr);
48
1.32k
    }
49
18.4E
    return nullptr;
50
1.32k
}
51
52
9
void register_aggregate_function_collect_list(AggregateFunctionSimpleFactory& factory) {
53
    // notice: array_agg only differs from collect_list in that array_agg will show null elements in array
54
9
    factory.register_function_both("collect_list", create_aggregate_function_collect);
55
9
    factory.register_function_both("collect_set", create_aggregate_function_collect);
56
9
    factory.register_alias("collect_list", "group_array");
57
9
    factory.register_alias("collect_set", "group_uniq_array");
58
9
}
59
} // namespace doris