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