Coverage Report

Created: 2026-03-15 08:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/aggregate/aggregate_function_percentile.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_percentile.h"
19
20
#include "core/types.h"
21
#include "exprs/aggregate/aggregate_function_simple_factory.h"
22
#include "exprs/aggregate/helpers.h"
23
24
namespace doris {
25
#include "common/compile_check_begin.h"
26
27
AggregateFunctionPtr create_aggregate_function_percentile_approx(
28
        const std::string& name, const DataTypes& argument_types, const DataTypePtr& result_type,
29
0
        const bool result_is_nullable, const AggregateFunctionAttr& attr) {
30
0
    const DataTypePtr& argument_type = remove_nullable(argument_types[0]);
31
0
    if (argument_type->get_primitive_type() != PrimitiveType::TYPE_DOUBLE) {
32
0
        return nullptr;
33
0
    }
34
0
    if (argument_types.size() == 2) {
35
0
        return creator_without_type::create<AggregateFunctionPercentileApproxTwoParams>(
36
0
                argument_types, result_is_nullable, attr);
37
0
    }
38
0
    if (argument_types.size() == 3) {
39
0
        return creator_without_type::create<AggregateFunctionPercentileApproxThreeParams>(
40
0
                argument_types, result_is_nullable, attr);
41
0
    }
42
0
    return nullptr;
43
0
}
44
45
AggregateFunctionPtr create_aggregate_function_percentile_approx_weighted(
46
        const std::string& name, const DataTypes& argument_types, const DataTypePtr& result_type,
47
0
        const bool result_is_nullable, const AggregateFunctionAttr& attr) {
48
0
    const DataTypePtr& argument_type = remove_nullable(argument_types[0]);
49
0
    if (argument_type->get_primitive_type() != PrimitiveType::TYPE_DOUBLE) {
50
0
        return nullptr;
51
0
    }
52
0
    if (argument_types.size() == 3) {
53
0
        return creator_without_type::create<AggregateFunctionPercentileApproxWeightedThreeParams>(
54
0
                argument_types, result_is_nullable, attr);
55
0
    }
56
0
    if (argument_types.size() == 4) {
57
0
        return creator_without_type::create<AggregateFunctionPercentileApproxWeightedFourParams>(
58
0
                argument_types, result_is_nullable, attr);
59
0
    }
60
0
    return nullptr;
61
0
}
62
63
1
void register_aggregate_function_percentile(AggregateFunctionSimpleFactory& factory) {
64
1
    using creator = creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT,
65
1
                                           TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE>;
66
1
    factory.register_function_both("percentile", creator::creator<AggregateFunctionPercentile>);
67
1
    factory.register_alias("percentile", "percentile_cont");
68
1
    factory.register_function_both("percentile_array",
69
1
                                   creator::creator<AggregateFunctionPercentileArray>);
70
1
}
71
72
1
void register_percentile_approx_old_function(AggregateFunctionSimpleFactory& factory) {
73
1
    BeExecVersionManager::registe_restrict_function_compatibility("percentile_approx");
74
1
    BeExecVersionManager::registe_restrict_function_compatibility("percentile_approx_weighted");
75
1
}
76
77
1
void register_aggregate_function_percentile_old(AggregateFunctionSimpleFactory& factory) {
78
1
    BeExecVersionManager::registe_restrict_function_compatibility("percentile");
79
1
    BeExecVersionManager::registe_restrict_function_compatibility("percentile_array");
80
1
}
81
82
1
void register_aggregate_function_percentile_approx(AggregateFunctionSimpleFactory& factory) {
83
1
    factory.register_function_both("percentile_approx",
84
1
                                   create_aggregate_function_percentile_approx);
85
1
    factory.register_function_both("percentile_approx_weighted",
86
1
                                   create_aggregate_function_percentile_approx_weighted);
87
88
1
    register_percentile_approx_old_function(factory);
89
1
}
90
91
#include "common/compile_check_end.h"
92
} // namespace doris