Coverage Report

Created: 2026-03-16 15:31

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
#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
0
                                                  const AggregateFunctionAttr& attr) {
38
0
    return creator_without_type::create<Function<Data<TYPE_DOUBLE, Name, is_stddev>>>(
39
0
            argument_types, result_is_nullable, attr);
40
0
}
Unexecuted instantiation: _ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_16VarianceSampNameENS_8SampDataELb0EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
Unexecuted instantiation: _ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_12VarianceNameENS_7PopDataELb0EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
Unexecuted instantiation: _ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_10StddevNameENS_7PopDataELb1EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
Unexecuted instantiation: _ZN5doris28create_function_single_valueINS_29AggregateFunctionSampVarianceENS_14StddevSampNameENS_8SampDataELb1EEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS4_IKNS_9IDataTypeEESaISI_EERKSI_bRKNS_21AggregateFunctionAttrE
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
0
                                                             const AggregateFunctionAttr& attr) {
47
0
    return create_function_single_value<AggregateFunctionSampVariance, VarianceSampName, SampData,
48
0
                                        false>(name, argument_types, result_type,
49
0
                                               result_is_nullable, attr);
50
0
}
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
0
                                                            const AggregateFunctionAttr& attr) {
57
0
    return create_function_single_value<AggregateFunctionSampVariance, VarianceName, PopData,
58
0
                                        false>(name, argument_types, result_type,
59
0
                                               result_is_nullable, attr);
60
0
}
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
0
                                                          const AggregateFunctionAttr& attr) {
67
0
    return create_function_single_value<AggregateFunctionSampVariance, StddevName, PopData, true>(
68
0
            name, argument_types, result_type, result_is_nullable, attr);
69
0
}
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
0
                                                           const AggregateFunctionAttr& attr) {
76
0
    return create_function_single_value<AggregateFunctionSampVariance, StddevSampName, SampData,
77
0
                                        true>(name, argument_types, result_type, result_is_nullable,
78
0
                                              attr);
79
0
}
80
81
1
void register_aggregate_function_stddev_variance_pop(AggregateFunctionSimpleFactory& factory) {
82
1
    factory.register_function_both("variance", create_aggregate_function_variance_pop);
83
1
    factory.register_alias("variance", "var_pop");
84
1
    factory.register_alias("variance", "variance_pop");
85
1
    factory.register_function_both("stddev", create_aggregate_function_stddev_pop);
86
1
    factory.register_alias("stddev", "stddev_pop");
87
1
    factory.register_alias("stddev", "std");
88
1
}
89
90
1
void register_aggregate_function_stddev_variance_samp_old(AggregateFunctionSimpleFactory& factory) {
91
1
    BeExecVersionManager::registe_restrict_function_compatibility("variance_samp");
92
1
    BeExecVersionManager::registe_restrict_function_compatibility("stddev_samp");
93
1
}
94
95
1
void register_aggregate_function_stddev_variance_samp(AggregateFunctionSimpleFactory& factory) {
96
1
    factory.register_function_both("variance_samp", create_aggregate_function_variance_samp);
97
1
    factory.register_alias("variance_samp", "var_samp");
98
1
    factory.register_function_both("stddev_samp", create_aggregate_function_stddev_samp);
99
1
    register_aggregate_function_stddev_variance_samp_old(factory);
100
1
}
101
} // namespace doris