Coverage Report

Created: 2026-04-08 12:28

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
5
void register_aggregate_function_sum(AggregateFunctionSimpleFactory& factory) {
30
5
    AggregateFunctionCreator creator = [&](const std::string& name, const DataTypes& types,
31
5
                                           const DataTypePtr& result_type,
32
5
                                           const bool result_is_nullable,
33
218
                                           const AggregateFunctionAttr& attr) {
34
218
        if (is_decimalv3(types[0]->get_primitive_type())) {
35
            // for decimalv3, use result type from FE plan
36
0
            return creator_with_type_list<TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMAL128I,
37
0
                                          TYPE_DECIMAL256>::
38
0
                    creator_with_result_type<AggregateFunctionSumDecimalV3>(
39
0
                            name, types, result_type, result_is_nullable, attr);
40
218
        } else {
41
            // TODO: for other types, also use result type from FE plan
42
218
            return creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT,
43
218
                                          TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMALV2>::
44
218
                    creator<AggregateFunctionSumSimple>(name, types, result_type,
45
218
                                                        result_is_nullable, attr);
46
218
        }
47
218
    };
48
5
    factory.register_function_both("sum", creator);
49
5
    factory.register_alias("sum", "sum0");
50
5
}
51
52
} // namespace doris