be/src/exprs/aggregate/aggregate_function_stddev.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_stddev.h" |
19 | | |
20 | | #include <fmt/format.h> |
21 | | |
22 | | #include <string> |
23 | | |
24 | | #include "core/data_type/data_type.h" |
25 | | #include "exprs/aggregate/aggregate_function_simple_factory.h" |
26 | | #include "exprs/aggregate/helpers.h" |
27 | | |
28 | | namespace doris { |
29 | | #include "common/compile_check_begin.h" |
30 | | |
31 | | template <template <typename> class Function, typename Name, |
32 | | template <PrimitiveType, typename, bool> class Data, bool is_stddev> |
33 | | AggregateFunctionPtr create_function_single_value(const String& name, |
34 | | const DataTypes& argument_types, |
35 | | const DataTypePtr& result_type, |
36 | | const bool result_is_nullable, |
37 | 3.98k | const AggregateFunctionAttr& attr) { |
38 | 3.98k | return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>( |
39 | 3.98k | argument_types, result_is_nullable, attr); |
40 | 3.98k | } _ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_16VarianceSampNameENS_8SampDataELb0EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE Line | Count | Source | 37 | 1.09k | const AggregateFunctionAttr& attr) { | 38 | 1.09k | return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>( | 39 | 1.09k | argument_types, result_is_nullable, attr); | 40 | 1.09k | } |
_ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_12VarianceNameENS_7PopDataELb0EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE Line | Count | Source | 37 | 1.15k | const AggregateFunctionAttr& attr) { | 38 | 1.15k | return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>( | 39 | 1.15k | argument_types, result_is_nullable, attr); | 40 | 1.15k | } |
_ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_10StddevNameENS_7PopDataELb1EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE Line | Count | Source | 37 | 1.11k | const AggregateFunctionAttr& attr) { | 38 | 1.11k | return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>( | 39 | 1.11k | argument_types, result_is_nullable, attr); | 40 | 1.11k | } |
_ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_14StddevSampNameENS_8SampDataELb1EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE Line | Count | Source | 37 | 623 | const AggregateFunctionAttr& attr) { | 38 | 623 | return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>( | 39 | 623 | argument_types, result_is_nullable, attr); | 40 | 623 | } |
|
41 | | |
42 | | AggregateFunctionPtr create_aggregate_function_variance_samp(const std::string& name, |
43 | | const DataTypes& argument_types, |
44 | | const DataTypePtr& result_type, |
45 | | const bool result_is_nullable, |
46 | 1.09k | const AggregateFunctionAttr& attr) { |
47 | 1.09k | return create_function_single_value<AggregateFunctionSampVariance, VarianceSampName, SampData, |
48 | 1.09k | false>(name, argument_types, result_type, |
49 | 1.09k | result_is_nullable, attr); |
50 | 1.09k | } |
51 | | |
52 | | AggregateFunctionPtr create_aggregate_function_variance_pop(const std::string& name, |
53 | | const DataTypes& argument_types, |
54 | | const DataTypePtr& result_type, |
55 | | const bool result_is_nullable, |
56 | 1.15k | const AggregateFunctionAttr& attr) { |
57 | 1.15k | return create_function_single_value<AggregateFunctionSampVariance, VarianceName, PopData, |
58 | 1.15k | false>(name, argument_types, result_type, |
59 | 1.15k | result_is_nullable, attr); |
60 | 1.15k | } |
61 | | |
62 | | AggregateFunctionPtr create_aggregate_function_stddev_pop(const std::string& name, |
63 | | const DataTypes& argument_types, |
64 | | const DataTypePtr& result_type, |
65 | | const bool result_is_nullable, |
66 | 1.11k | const AggregateFunctionAttr& attr) { |
67 | 1.11k | return create_function_single_value<AggregateFunctionSampVariance, StddevName, PopData, true>( |
68 | 1.11k | name, argument_types, result_type, result_is_nullable, attr); |
69 | 1.11k | } |
70 | | |
71 | | AggregateFunctionPtr create_aggregate_function_stddev_samp(const std::string& name, |
72 | | const DataTypes& argument_types, |
73 | | const DataTypePtr& result_type, |
74 | | const bool result_is_nullable, |
75 | 623 | const AggregateFunctionAttr& attr) { |
76 | 623 | return create_function_single_value<AggregateFunctionSampVariance, StddevSampName, SampData, |
77 | 623 | true>(name, argument_types, result_type, result_is_nullable, |
78 | 623 | attr); |
79 | 623 | } |
80 | | |
81 | 6 | void register_aggregate_function_stddev_variance_pop(AggregateFunctionSimpleFactory& factory) { |
82 | 6 | factory.register_function_both("variance", create_aggregate_function_variance_pop); |
83 | 6 | factory.register_alias("variance", "var_pop"); |
84 | 6 | factory.register_alias("variance", "variance_pop"); |
85 | 6 | factory.register_function_both("stddev", create_aggregate_function_stddev_pop); |
86 | 6 | factory.register_alias("stddev", "stddev_pop"); |
87 | 6 | factory.register_alias("stddev", "std"); |
88 | 6 | } |
89 | | |
90 | 6 | void register_aggregate_function_stddev_variance_samp_old(AggregateFunctionSimpleFactory& factory) { |
91 | 6 | BeExecVersionManager::registe_restrict_function_compatibility("variance_samp"); |
92 | 6 | BeExecVersionManager::registe_restrict_function_compatibility("stddev_samp"); |
93 | 6 | } |
94 | | |
95 | 6 | void register_aggregate_function_stddev_variance_samp(AggregateFunctionSimpleFactory& factory) { |
96 | 6 | factory.register_function_both("variance_samp", create_aggregate_function_variance_samp); |
97 | 6 | factory.register_alias("variance_samp", "var_samp"); |
98 | 6 | factory.register_function_both("stddev_samp", create_aggregate_function_stddev_samp); |
99 | 6 | register_aggregate_function_stddev_variance_samp_old(factory); |
100 | 6 | } |
101 | | } // namespace doris |