be/src/exprs/aggregate/aggregate_function_topn_array.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 "core/data_type/data_type.h" |
19 | | #include "core/data_type/define_primitive_type.h" |
20 | | #include "exprs/aggregate/aggregate_function_topn.h" |
21 | | #include "exprs/aggregate/helpers.h" |
22 | | |
23 | | namespace doris { |
24 | | #include "common/compile_check_begin.h" |
25 | | |
26 | | template <PrimitiveType T> |
27 | | using ImplArray = AggregateFunctionTopNImplArray<T, false>; |
28 | | template <PrimitiveType T> |
29 | | using ImplArrayWithDefault = AggregateFunctionTopNImplArray<T, true>; |
30 | | |
31 | | using topn_array_creator = |
32 | | creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT, TYPE_LARGEINT, |
33 | | TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMAL32, TYPE_DECIMAL64, |
34 | | TYPE_DECIMAL128I, TYPE_DECIMAL256, TYPE_VARCHAR, TYPE_DATEV2, |
35 | | TYPE_DATETIMEV2, TYPE_TIMESTAMPTZ, TYPE_IPV4, TYPE_IPV6>; |
36 | | |
37 | | AggregateFunctionPtr create_aggregate_function_topn_array(const std::string& name, |
38 | | const DataTypes& argument_types, |
39 | | const DataTypePtr& result_type, |
40 | | const bool result_is_nullable, |
41 | 0 | const AggregateFunctionAttr& attr) { |
42 | 0 | bool has_default_param = (argument_types.size() == 3); |
43 | 0 | if (has_default_param) { |
44 | 0 | return topn_array_creator::create<AggregateFunctionTopNArray, ImplArrayWithDefault>( |
45 | 0 | argument_types, result_is_nullable, attr); |
46 | 0 | } else { |
47 | 0 | return topn_array_creator::create<AggregateFunctionTopNArray, ImplArray>( |
48 | 0 | argument_types, result_is_nullable, attr); |
49 | 0 | } |
50 | 0 | } |
51 | | |
52 | | } // namespace doris |