Coverage Report

Created: 2026-04-10 16:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
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
30
template <template <typename> class Function, typename Name,
31
          template <PrimitiveType, typename, bool> class Data, bool is_stddev>
32
AggregateFunctionPtr create_function_single_value(const String& name,
33
                                                  const DataTypes& argument_types,
34
                                                  const DataTypePtr& result_type,
35
                                                  const bool result_is_nullable,
36
3.42k
                                                  const AggregateFunctionAttr& attr) {
37
3.42k
    return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>(
38
3.42k
            argument_types, result_is_nullable, attr);
39
3.42k
}
_ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_16VarianceSampNameENS_8SampDataELb0EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
Line
Count
Source
36
943
                                                  const AggregateFunctionAttr& attr) {
37
943
    return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>(
38
943
            argument_types, result_is_nullable, attr);
39
943
}
_ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_12VarianceNameENS_7PopDataELb0EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
Line
Count
Source
36
985
                                                  const AggregateFunctionAttr& attr) {
37
985
    return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>(
38
985
            argument_types, result_is_nullable, attr);
39
985
}
_ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_10StddevNameENS_7PopDataELb1EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
Line
Count
Source
36
958
                                                  const AggregateFunctionAttr& attr) {
37
958
    return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>(
38
958
            argument_types, result_is_nullable, attr);
39
958
}
_ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_14StddevSampNameENS_8SampDataELb1EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
Line
Count
Source
36
537
                                                  const AggregateFunctionAttr& attr) {
37
537
    return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>(
38
537
            argument_types, result_is_nullable, attr);
39
537
}
40
41
AggregateFunctionPtr create_aggregate_function_variance_samp(const std::string& name,
42
                                                             const DataTypes& argument_types,
43
                                                             const DataTypePtr& result_type,
44
                                                             const bool result_is_nullable,
45
943
                                                             const AggregateFunctionAttr& attr) {
46
943
    return create_function_single_value<AggregateFunctionSampVariance, VarianceSampName, SampData,
47
943
                                        false>(name, argument_types, result_type,
48
943
                                               result_is_nullable, attr);
49
943
}
50
51
AggregateFunctionPtr create_aggregate_function_variance_pop(const std::string& name,
52
                                                            const DataTypes& argument_types,
53
                                                            const DataTypePtr& result_type,
54
                                                            const bool result_is_nullable,
55
985
                                                            const AggregateFunctionAttr& attr) {
56
985
    return create_function_single_value<AggregateFunctionSampVariance, VarianceName, PopData,
57
985
                                        false>(name, argument_types, result_type,
58
985
                                               result_is_nullable, attr);
59
985
}
60
61
AggregateFunctionPtr create_aggregate_function_stddev_pop(const std::string& name,
62
                                                          const DataTypes& argument_types,
63
                                                          const DataTypePtr& result_type,
64
                                                          const bool result_is_nullable,
65
958
                                                          const AggregateFunctionAttr& attr) {
66
958
    return create_function_single_value<AggregateFunctionSampVariance, StddevName, PopData, true>(
67
958
            name, argument_types, result_type, result_is_nullable, attr);
68
958
}
69
70
AggregateFunctionPtr create_aggregate_function_stddev_samp(const std::string& name,
71
                                                           const DataTypes& argument_types,
72
                                                           const DataTypePtr& result_type,
73
                                                           const bool result_is_nullable,
74
537
                                                           const AggregateFunctionAttr& attr) {
75
537
    return create_function_single_value<AggregateFunctionSampVariance, StddevSampName, SampData,
76
537
                                        true>(name, argument_types, result_type, result_is_nullable,
77
537
                                              attr);
78
537
}
79
80
6
void register_aggregate_function_stddev_variance_pop(AggregateFunctionSimpleFactory& factory) {
81
6
    factory.register_function_both("variance", create_aggregate_function_variance_pop);
82
6
    factory.register_alias("variance", "var_pop");
83
6
    factory.register_alias("variance", "variance_pop");
84
6
    factory.register_function_both("stddev", create_aggregate_function_stddev_pop);
85
6
    factory.register_alias("stddev", "stddev_pop");
86
6
    factory.register_alias("stddev", "std");
87
6
}
88
89
6
void register_aggregate_function_stddev_variance_samp_old(AggregateFunctionSimpleFactory& factory) {
90
6
    BeExecVersionManager::registe_restrict_function_compatibility("variance_samp");
91
6
    BeExecVersionManager::registe_restrict_function_compatibility("stddev_samp");
92
6
}
93
94
6
void register_aggregate_function_stddev_variance_samp(AggregateFunctionSimpleFactory& factory) {
95
6
    factory.register_function_both("variance_samp", create_aggregate_function_variance_samp);
96
6
    factory.register_alias("variance_samp", "var_samp");
97
6
    factory.register_function_both("stddev_samp", create_aggregate_function_stddev_samp);
98
6
    register_aggregate_function_stddev_variance_samp_old(factory);
99
6
}
100
} // namespace doris