be/src/exprs/aggregate/aggregate_function_histogram.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_histogram.h" |
19 | | |
20 | | #include <fmt/format.h> |
21 | | #include <glog/logging.h> |
22 | | |
23 | | #include "core/data_type/data_type.h" |
24 | | #include "core/data_type/define_primitive_type.h" |
25 | | #include "exprs/aggregate/factory_helpers.h" |
26 | | #include "exprs/aggregate/helpers.h" |
27 | | |
28 | | namespace doris { |
29 | | #include "common/compile_check_begin.h" |
30 | | |
31 | | template <typename Data> |
32 | | using HistogramWithInputParam = AggregateFunctionHistogram<Data, true>; |
33 | | |
34 | | template <typename Data> |
35 | | using HistogramNormal = AggregateFunctionHistogram<Data, false>; |
36 | | |
37 | | AggregateFunctionPtr create_aggregate_function_histogram(const std::string& name, |
38 | | const DataTypes& argument_types, |
39 | | const DataTypePtr& result_type, |
40 | | const bool result_is_nullable, |
41 | 875 | const AggregateFunctionAttr& attr) { |
42 | 875 | assert_arity_range(name, argument_types, 1, 2); |
43 | 875 | using creator = |
44 | 875 | creator_with_type_list<TYPE_BOOLEAN, TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT, |
45 | 875 | TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMAL32, |
46 | 875 | TYPE_DECIMAL64, TYPE_DECIMAL128I, TYPE_DECIMAL256, TYPE_VARCHAR, |
47 | 875 | TYPE_DATEV2, TYPE_DATETIMEV2>; |
48 | 875 | if (argument_types.size() == 2) { |
49 | 168 | return creator::create<HistogramWithInputParam, AggregateFunctionHistogramData>( |
50 | 168 | argument_types, result_is_nullable, attr); |
51 | 707 | } else { |
52 | 707 | return creator::create<HistogramNormal, AggregateFunctionHistogramData>( |
53 | 707 | argument_types, result_is_nullable, attr); |
54 | 707 | } |
55 | 875 | } |
56 | | |
57 | 8 | void register_aggregate_function_histogram(AggregateFunctionSimpleFactory& factory) { |
58 | 8 | factory.register_function_both("histogram", create_aggregate_function_histogram); |
59 | 8 | factory.register_alias("histogram", "hist"); |
60 | 8 | } |
61 | | |
62 | | } // namespace doris |