Coverage Report

Created: 2026-09-28 10:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/round.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/function/round.h"
19
20
#include "exprs/function/simple_function_factory.h"
21
22
namespace doris {
23
24
// We split round funcs from register_function_math() in math.cpp to here,
25
// so that to speed up compile time and make code more readable.
26
9
void register_function_round(SimpleFunctionFactory& factory) {
27
9
#define REGISTER_ROUND_FUNCTIONS(IMPL)                                                           \
28
18
    factory.register_function<                                                                   \
29
18
            FunctionRounding<IMPL<TruncateName>, RoundingMode::Trunc, TieBreakingMode::Auto>>(); \
30
18
    factory.register_function<                                                                   \
31
18
            FunctionRounding<IMPL<FloorName>, RoundingMode::Floor, TieBreakingMode::Auto>>();    \
32
18
    factory.register_function<                                                                   \
33
18
            FunctionRounding<IMPL<RoundName>, RoundingMode::Round, TieBreakingMode::Auto>>();    \
34
18
    factory.register_function<                                                                   \
35
18
            FunctionRounding<IMPL<CeilName>, RoundingMode::Ceil, TieBreakingMode::Auto>>();      \
36
18
    factory.register_function<FunctionRounding<IMPL<RoundBankersName>, RoundingMode::Round,      \
37
18
                                               TieBreakingMode::Bankers>>();
38
9
    REGISTER_ROUND_FUNCTIONS(DoubleRoundOneImpl)
39
9
    REGISTER_ROUND_FUNCTIONS(DoubleRoundTwoImpl)
40
9
#undef REGISTER_ROUND_FUNCTIONS
41
42
9
#define REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE)                                                 \
43
72
    factory.register_function<FunctionRounding<IMPL<TruncateName, TYPE>, RoundingMode::Trunc,     \
44
72
                                               TieBreakingMode::Auto>>();                         \
45
72
    factory.register_function<FunctionRounding<IMPL<FloorName, TYPE>, RoundingMode::Floor,        \
46
72
                                               TieBreakingMode::Auto>>();                         \
47
72
    factory.register_function<FunctionRounding<IMPL<RoundName, TYPE>, RoundingMode::Round,        \
48
72
                                               TieBreakingMode::Auto>>();                         \
49
72
    factory.register_function<                                                                    \
50
72
            FunctionRounding<IMPL<CeilName, TYPE>, RoundingMode::Ceil, TieBreakingMode::Auto>>(); \
51
72
    factory.register_function<FunctionRounding<IMPL<RoundBankersName, TYPE>, RoundingMode::Round, \
52
72
                                               TieBreakingMode::Bankers>>();
53
54
9
#define REGISTER_ROUND_FUNCTIONS(IMPL)                    \
55
18
    REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL32)   \
56
18
    REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL64)   \
57
18
    REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL128I) \
58
18
    REGISTER_ROUND_FUNCTIONS_IMPL(IMPL, TYPE_DECIMAL256)
59
9
    REGISTER_ROUND_FUNCTIONS(DecimalRoundOneImpl)
60
9
    REGISTER_ROUND_FUNCTIONS(DecimalRoundTwoImpl)
61
9
#undef REGISTER_ROUND_FUNCTIONS
62
9
#undef REGISTER_ROUND_FUNCTIONS_IMPL
63
64
9
    factory.register_alias("ceil", "dceil");
65
9
    factory.register_alias("ceil", "ceiling");
66
9
    factory.register_alias("floor", "dfloor");
67
9
    factory.register_alias("round", "dround");
68
9
}
69
70
} // namespace doris