Coverage Report

Created: 2026-03-14 18:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/aggregate/aggregate_function_sum.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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/AggregateFunctions/AggregateFunctionSum.cpp
19
// and modified by Doris
20
21
#include "exprs/aggregate/aggregate_function_sum.h"
22
23
#include "exprs/aggregate/aggregate_function_simple_factory.h"
24
#include "exprs/aggregate/helpers.h"
25
26
namespace doris {
27
#include "common/compile_check_begin.h"
28
29
8
void register_aggregate_function_sum(AggregateFunctionSimpleFactory& factory) {
30
8
    AggregateFunctionCreator creator = [&](const std::string& name, const DataTypes& types,
31
8
                                           const DataTypePtr& result_type,
32
8
                                           const bool result_is_nullable,
33
13.6k
                                           const AggregateFunctionAttr& attr) {
34
13.6k
        if (is_decimalv3(types[0]->get_primitive_type())) {
35
            // for decimalv3, use result type from FE plan
36
2.32k
            return creator_with_type_list<TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMAL128I,
37
2.32k
                                          TYPE_DECIMAL256>::
38
2.32k
                    creator_with_result_type<AggregateFunctionSumDecimalV3>(
39
2.32k
                            name, types, result_type, result_is_nullable, attr);
40
11.3k
        } else {
41
            // TODO: for other types, also use result type from FE plan
42
11.3k
            return creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT,
43
11.3k
                                          TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMALV2>::
44
11.3k
                    creator<AggregateFunctionSumSimple>(name, types, result_type,
45
11.3k
                                                        result_is_nullable, attr);
46
11.3k
        }
47
13.6k
    };
48
8
    factory.register_function_both("sum", creator);
49
8
    factory.register_alias("sum", "sum0");
50
8
}
51
52
} // namespace doris