Coverage Report

Created: 2026-03-13 09:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/math.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 <cstddef>
19
#include <cstdint>
20
#include <cstring>
21
22
// IWYU pragma: no_include <bits/std_abs.h>
23
#include <dlfcn.h>
24
25
#include <cmath>
26
#include <string>
27
#include <type_traits>
28
29
#include "common/status.h"
30
#include "core/column/column.h"
31
#include "core/column/column_string.h"
32
#include "core/column/column_vector.h"
33
#include "core/data_type/data_type_string.h"
34
#include "core/data_type/data_type_struct.h"
35
#include "core/data_type/define_primitive_type.h"
36
#include "core/data_type/number_traits.h"
37
#include "core/field.h"
38
#include "core/types.h"
39
#include "exec/common/stringop_substring.h"
40
#include "exprs/aggregate/aggregate_function.h"
41
#include "exprs/function/function_const.h"
42
#include "exprs/function/function_math_log.h"
43
#include "exprs/function/function_math_unary.h"
44
#include "exprs/function/function_math_unary_alway_nullable.h"
45
#include "exprs/function/function_totype.h"
46
#include "exprs/function/function_unary_arithmetic.h"
47
#include "exprs/function/simple_function_factory.h"
48
49
namespace doris {
50
51
struct AcosName {
52
    static constexpr auto name = "acos";
53
    // https://dev.mysql.com/doc/refman/8.4/en/mathematical-functions.html#function_acos
54
39
    static constexpr bool is_invalid_input(Float64 x) { return x < -1 || x > 1; }
55
};
56
using FunctionAcos =
57
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<AcosName, std::acos>>;
58
59
struct AcoshName {
60
    static constexpr auto name = "acosh";
61
20
    static constexpr bool is_invalid_input(Float64 x) { return x < 1; }
62
};
63
using FunctionAcosh =
64
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<AcoshName, std::acosh>>;
65
66
struct AsinName {
67
    static constexpr auto name = "asin";
68
    // https://dev.mysql.com/doc/refman/8.4/en/mathematical-functions.html#function_asin
69
75
    static constexpr bool is_invalid_input(Float64 x) { return x < -1 || x > 1; }
70
};
71
using FunctionAsin =
72
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<AsinName, std::asin>>;
73
74
struct AsinhName {
75
    static constexpr auto name = "asinh";
76
};
77
using FunctionAsinh = FunctionMathUnary<UnaryFunctionPlain<AsinhName, std::asinh>>;
78
79
class FunctionAtan : public IFunction {
80
public:
81
    static constexpr auto name = "atan";
82
16
    static FunctionPtr create() { return std::make_shared<FunctionAtan>(); }
83
84
0
    String get_name() const override { return name; }
85
8
    bool is_variadic() const override { return true; }
86
0
    size_t get_number_of_arguments() const override { return 0; }
87
88
7
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
89
7
        return std::make_shared<DataTypeFloat64>();
90
7
    }
91
92
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
93
13
                        uint32_t result, size_t input_rows_count) const override {
94
13
        if (arguments.size() == 1) {
95
10
            return execute_unary(block, arguments, result, input_rows_count);
96
10
        } else if (arguments.size() == 2) {
97
3
            return execute_binary(block, arguments, result, input_rows_count);
98
3
        } else {
99
0
            return Status::InvalidArgument("atan function expects 1 or 2 arguments, but got {}",
100
0
                                           arguments.size());
101
0
        }
102
13
    }
103
104
private:
105
    Status execute_unary(Block& block, const ColumnNumbers& arguments, uint32_t result,
106
10
                         size_t input_rows_count) const {
107
10
        auto res_col = ColumnFloat64::create(input_rows_count);
108
10
        auto& res_data = res_col->get_data();
109
110
10
        const auto& col_data =
111
10
                assert_cast<const ColumnFloat64*>(block.get_by_position(arguments[0]).column.get())
112
10
                        ->get_data();
113
68
        for (size_t i = 0; i < input_rows_count; ++i) {
114
58
            res_data[i] = std::atan(col_data[i]);
115
58
        }
116
117
10
        block.replace_by_position(result, std::move(res_col));
118
10
        return Status::OK();
119
10
    }
120
121
    Status execute_binary(Block& block, const ColumnNumbers& arguments, uint32_t result,
122
3
                          size_t input_rows_count) const {
123
3
        auto [col_y, is_const_y] = unpack_if_const(block.get_by_position(arguments[0]).column);
124
3
        auto [col_x, is_const_x] = unpack_if_const(block.get_by_position(arguments[1]).column);
125
126
3
        auto result_column = ColumnFloat64::create(input_rows_count);
127
3
        auto& result_data = result_column->get_data();
128
129
3
        if (is_const_y) {
130
1
            auto y_val = assert_cast<const ColumnFloat64*>(col_y.get())->get_element(0);
131
132
1
            const auto* x_col = assert_cast<const ColumnFloat64*>(col_x.get());
133
1
            const auto& x_data = x_col->get_data();
134
30
            for (size_t i = 0; i < input_rows_count; ++i) {
135
29
                result_data[i] = std::atan2(y_val, x_data[i]);
136
29
            }
137
2
        } else if (is_const_x) {
138
1
            auto x_val = assert_cast<const ColumnFloat64*>(col_x.get())->get_element(0);
139
140
1
            const auto* y_col = assert_cast<const ColumnFloat64*>(col_y.get());
141
1
            const auto& y_data = y_col->get_data();
142
30
            for (size_t i = 0; i < input_rows_count; ++i) {
143
29
                result_data[i] = std::atan2(y_data[i], x_val);
144
29
            }
145
1
        } else {
146
1
            const auto* y_col = assert_cast<const ColumnFloat64*>(col_y.get());
147
1
            const auto* x_col = assert_cast<const ColumnFloat64*>(col_x.get());
148
1
            const auto& y_data = y_col->get_data();
149
1
            const auto& x_data = x_col->get_data();
150
30
            for (size_t i = 0; i < input_rows_count; ++i) {
151
29
                result_data[i] = std::atan2(y_data[i], x_data[i]);
152
29
            }
153
1
        }
154
155
3
        block.replace_by_position(result, std::move(result_column));
156
3
        return Status::OK();
157
3
    }
158
};
159
160
struct AtanhName {
161
    static constexpr auto name = "atanh";
162
20
    static constexpr bool is_invalid_input(Float64 x) { return x <= -1 || x >= 1; }
163
};
164
using FunctionAtanh =
165
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<AtanhName, std::atanh>>;
166
167
struct CosName {
168
    static constexpr auto name = "cos";
169
};
170
using FunctionCos = FunctionMathUnary<UnaryFunctionPlain<CosName, std::cos>>;
171
172
struct CoshName {
173
    static constexpr auto name = "cosh";
174
};
175
using FunctionCosh = FunctionMathUnary<UnaryFunctionPlain<CoshName, std::cosh>>;
176
177
struct EImpl {
178
    static constexpr auto name = "e";
179
    static constexpr double value = 2.7182818284590452353602874713526624977572470;
180
};
181
using FunctionE = FunctionMathConstFloat64<EImpl>;
182
183
struct PiImpl {
184
    static constexpr auto name = "pi";
185
    static constexpr double value = 3.1415926535897932384626433832795028841971693;
186
};
187
using FunctionPi = FunctionMathConstFloat64<PiImpl>;
188
189
struct ExpName {
190
    static constexpr auto name = "exp";
191
};
192
using FunctionExp = FunctionMathUnary<UnaryFunctionPlain<ExpName, std::exp>>;
193
194
template <typename A>
195
struct SignImpl {
196
    static constexpr PrimitiveType ResultType = TYPE_TINYINT;
197
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
198
57
    static inline UInt8 apply(A a) {
199
57
        if constexpr (IsDecimalNumber<A> || std::is_floating_point_v<A>) {
200
57
            return static_cast<UInt8>(a < A(0) ? -1 : a == A(0) ? 0 : 1);
201
        } else if constexpr (IsSignedV<A>) {
202
            return static_cast<UInt8>(a < 0 ? -1 : a == 0 ? 0 : 1);
203
        } else {
204
            static_assert(std::is_same_v<A, void>, "Unsupported type in SignImpl");
205
        }
206
57
    }
207
};
208
209
struct NameSign {
210
    static constexpr auto name = "sign";
211
};
212
using FunctionSign = FunctionUnaryArithmetic<SignImpl<double>, NameSign, TYPE_DOUBLE>;
213
214
template <typename A>
215
struct AbsImpl {
216
    static constexpr PrimitiveType ResultType = NumberTraits::ResultOfAbs<A>::Type;
217
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
218
1.06M
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
1.06M
        if constexpr (IsDecimal128V2<A>) {
220
0
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
26.7k
        } else if constexpr (IsDecimalNumber<A>) {
222
26.7k
            return a < A(0) ? A(-a) : a;
223
615k
        } else if constexpr (IsIntegralV<A>) {
224
615k
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
615k
                            : a;
226
615k
        } else if constexpr (std::is_floating_point_v<A>) {
227
422k
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
1.06M
    }
_ZN5doris7AbsImplIaE5applyEa
Line
Count
Source
218
26.1k
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
        } else if constexpr (IsDecimalNumber<A>) {
222
            return a < A(0) ? A(-a) : a;
223
26.1k
        } else if constexpr (IsIntegralV<A>) {
224
26.1k
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
26.1k
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
26.1k
    }
_ZN5doris7AbsImplIsE5applyEs
Line
Count
Source
218
26.2k
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
        } else if constexpr (IsDecimalNumber<A>) {
222
            return a < A(0) ? A(-a) : a;
223
26.2k
        } else if constexpr (IsIntegralV<A>) {
224
26.2k
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
26.2k
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
26.2k
    }
_ZN5doris7AbsImplIiE5applyEi
Line
Count
Source
218
378k
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
        } else if constexpr (IsDecimalNumber<A>) {
222
            return a < A(0) ? A(-a) : a;
223
378k
        } else if constexpr (IsIntegralV<A>) {
224
378k
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
378k
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
378k
    }
_ZN5doris7AbsImplIlE5applyEl
Line
Count
Source
218
184k
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
        } else if constexpr (IsDecimalNumber<A>) {
222
            return a < A(0) ? A(-a) : a;
223
184k
        } else if constexpr (IsIntegralV<A>) {
224
184k
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
184k
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
184k
    }
_ZN5doris7AbsImplInE5applyEn
Line
Count
Source
218
75
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
        } else if constexpr (IsDecimalNumber<A>) {
222
            return a < A(0) ? A(-a) : a;
223
75
        } else if constexpr (IsIntegralV<A>) {
224
75
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
75
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
75
    }
Unexecuted instantiation: _ZN5doris7AbsImplIhE5applyEh
_ZN5doris7AbsImplINS_7DecimalIiEEE5applyES2_
Line
Count
Source
218
111
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
111
        } else if constexpr (IsDecimalNumber<A>) {
222
111
            return a < A(0) ? A(-a) : a;
223
        } else if constexpr (IsIntegralV<A>) {
224
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
111
    }
_ZN5doris7AbsImplINS_7DecimalIlEEE5applyES2_
Line
Count
Source
218
26.5k
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
26.5k
        } else if constexpr (IsDecimalNumber<A>) {
222
26.5k
            return a < A(0) ? A(-a) : a;
223
        } else if constexpr (IsIntegralV<A>) {
224
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
26.5k
    }
_ZN5doris7AbsImplINS_12Decimal128V3EE5applyES1_
Line
Count
Source
218
51
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
51
        } else if constexpr (IsDecimalNumber<A>) {
222
51
            return a < A(0) ? A(-a) : a;
223
        } else if constexpr (IsIntegralV<A>) {
224
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
51
    }
Unexecuted instantiation: _ZN5doris7AbsImplINS_14DecimalV2ValueEE5applyES1_
_ZN5doris7AbsImplINS_7DecimalIN4wide7integerILm256EiEEEEE5applyES5_
Line
Count
Source
218
30
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
30
        } else if constexpr (IsDecimalNumber<A>) {
222
30
            return a < A(0) ? A(-a) : a;
223
        } else if constexpr (IsIntegralV<A>) {
224
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
                            : a;
226
        } else if constexpr (std::is_floating_point_v<A>) {
227
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
30
    }
_ZN5doris7AbsImplIfE5applyEf
Line
Count
Source
218
84.5k
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
        } else if constexpr (IsDecimalNumber<A>) {
222
            return a < A(0) ? A(-a) : a;
223
        } else if constexpr (IsIntegralV<A>) {
224
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
                            : a;
226
84.5k
        } else if constexpr (std::is_floating_point_v<A>) {
227
84.5k
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
84.5k
    }
_ZN5doris7AbsImplIdE5applyEd
Line
Count
Source
218
337k
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
        } else if constexpr (IsDecimalNumber<A>) {
222
            return a < A(0) ? A(-a) : a;
223
        } else if constexpr (IsIntegralV<A>) {
224
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
                            : a;
226
337k
        } else if constexpr (std::is_floating_point_v<A>) {
227
337k
            return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(std::abs(a));
228
        } else {
229
            static_assert(std::is_same_v<A, void>, "Unsupported type in AbsImpl");
230
        }
231
337k
    }
232
};
233
234
struct NameAbs {
235
    static constexpr auto name = "abs";
236
};
237
238
template <typename A>
239
struct ResultOfPosAndNegTive;
240
241
template <>
242
struct ResultOfPosAndNegTive<Int64> {
243
    static constexpr PrimitiveType ResultType = TYPE_BIGINT;
244
};
245
template <>
246
struct ResultOfPosAndNegTive<double> {
247
    static constexpr PrimitiveType ResultType = TYPE_DOUBLE;
248
};
249
250
template <>
251
struct ResultOfPosAndNegTive<Decimal32> {
252
    static constexpr PrimitiveType ResultType = TYPE_DECIMAL32;
253
};
254
255
template <>
256
struct ResultOfPosAndNegTive<Decimal64> {
257
    static constexpr PrimitiveType ResultType = TYPE_DECIMAL64;
258
};
259
260
template <>
261
struct ResultOfPosAndNegTive<Decimal128V2> {
262
    static constexpr PrimitiveType ResultType = TYPE_DECIMALV2;
263
};
264
265
template <>
266
struct ResultOfPosAndNegTive<DecimalV2Value> {
267
    static constexpr PrimitiveType ResultType = TYPE_DECIMALV2;
268
};
269
270
template <>
271
struct ResultOfPosAndNegTive<Decimal128V3> {
272
    static constexpr PrimitiveType ResultType = TYPE_DECIMAL128I;
273
};
274
275
template <>
276
struct ResultOfPosAndNegTive<Decimal256> {
277
    static constexpr PrimitiveType ResultType = TYPE_DECIMAL256;
278
};
279
280
using FunctionAbsUInt8 = FunctionUnaryArithmetic<AbsImpl<UInt8>, NameAbs, TYPE_BOOLEAN>;
281
using FunctionAbsInt8 = FunctionUnaryArithmetic<AbsImpl<Int8>, NameAbs, TYPE_TINYINT>;
282
using FunctionAbsInt16 = FunctionUnaryArithmetic<AbsImpl<Int16>, NameAbs, TYPE_SMALLINT>;
283
using FunctionAbsInt32 = FunctionUnaryArithmetic<AbsImpl<Int32>, NameAbs, TYPE_INT>;
284
using FunctionAbsInt64 = FunctionUnaryArithmetic<AbsImpl<Int64>, NameAbs, TYPE_BIGINT>;
285
using FunctionAbsInt128 = FunctionUnaryArithmetic<AbsImpl<Int128>, NameAbs, TYPE_LARGEINT>;
286
using FunctionAbsDecimal32 = FunctionUnaryArithmetic<AbsImpl<Decimal32>, NameAbs, TYPE_DECIMAL32>;
287
using FunctionAbsDecimal64 = FunctionUnaryArithmetic<AbsImpl<Decimal64>, NameAbs, TYPE_DECIMAL64>;
288
using FunctionAbsDecimalV3 =
289
        FunctionUnaryArithmetic<AbsImpl<Decimal128V3>, NameAbs, TYPE_DECIMAL128I>;
290
using FunctionAbsDecimalV2 =
291
        FunctionUnaryArithmetic<AbsImpl<DecimalV2Value>, NameAbs, TYPE_DECIMALV2>;
292
using FunctionAbsDecimal256 =
293
        FunctionUnaryArithmetic<AbsImpl<Decimal256>, NameAbs, TYPE_DECIMAL256>;
294
using FunctionAbsFloat = FunctionUnaryArithmetic<AbsImpl<float>, NameAbs, TYPE_FLOAT>;
295
using FunctionAbsDouble = FunctionUnaryArithmetic<AbsImpl<double>, NameAbs, TYPE_DOUBLE>;
296
297
template <typename A>
298
struct NegativeImpl {
299
    static constexpr PrimitiveType ResultType = ResultOfPosAndNegTive<A>::ResultType;
300
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
301
    NO_SANITIZE_UNDEFINED static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(
302
105
            A a) {
303
105
        return -a;
304
105
    }
_ZN5doris12NegativeImplIdE5applyEd
Line
Count
Source
302
37
            A a) {
303
37
        return -a;
304
37
    }
_ZN5doris12NegativeImplIlE5applyEl
Line
Count
Source
302
39
            A a) {
303
39
        return -a;
304
39
    }
Unexecuted instantiation: _ZN5doris12NegativeImplINS_14DecimalV2ValueEE5applyES1_
Unexecuted instantiation: _ZN5doris12NegativeImplINS_7DecimalIN4wide7integerILm256EiEEEEE5applyES5_
Unexecuted instantiation: _ZN5doris12NegativeImplINS_12Decimal128V3EE5applyES1_
_ZN5doris12NegativeImplINS_7DecimalIiEEE5applyES2_
Line
Count
Source
302
29
            A a) {
303
29
        return -a;
304
29
    }
Unexecuted instantiation: _ZN5doris12NegativeImplINS_7DecimalIlEEE5applyES2_
305
};
306
307
struct NameNegative {
308
    static constexpr auto name = "negative";
309
};
310
311
using FunctionNegativeDouble =
312
        FunctionUnaryArithmetic<NegativeImpl<double>, NameNegative, TYPE_DOUBLE>;
313
using FunctionNegativeBigInt =
314
        FunctionUnaryArithmetic<NegativeImpl<Int64>, NameNegative, TYPE_BIGINT>;
315
using FunctionNegativeDecimalV2 =
316
        FunctionUnaryArithmetic<NegativeImpl<DecimalV2Value>, NameNegative, TYPE_DECIMALV2>;
317
using FunctionNegativeDecimal256 =
318
        FunctionUnaryArithmetic<NegativeImpl<Decimal256>, NameNegative, TYPE_DECIMAL256>;
319
using FunctionNegativeDecimalV3 =
320
        FunctionUnaryArithmetic<NegativeImpl<Decimal128V3>, NameNegative, TYPE_DECIMAL128I>;
321
using FunctionNegativeDecimal32 =
322
        FunctionUnaryArithmetic<NegativeImpl<Decimal32>, NameNegative, TYPE_DECIMAL32>;
323
using FunctionNegativeDecimal64 =
324
        FunctionUnaryArithmetic<NegativeImpl<Decimal64>, NameNegative, TYPE_DECIMAL64>;
325
326
template <typename A>
327
struct PositiveImpl {
328
    static constexpr PrimitiveType ResultType = ResultOfPosAndNegTive<A>::ResultType;
329
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
330
108
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
331
108
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a);
332
108
    }
_ZN5doris12PositiveImplINS_7DecimalIiEEE5applyES2_
Line
Count
Source
330
27
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
331
27
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a);
332
27
    }
_ZN5doris12PositiveImplINS_7DecimalIlEEE5applyES2_
Line
Count
Source
330
4
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
331
4
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a);
332
4
    }
_ZN5doris12PositiveImplINS_12Decimal128V3EE5applyES1_
Line
Count
Source
330
17
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
331
17
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a);
332
17
    }
Unexecuted instantiation: _ZN5doris12PositiveImplINS_14DecimalV2ValueEE5applyES1_
Unexecuted instantiation: _ZN5doris12PositiveImplINS_7DecimalIN4wide7integerILm256EiEEEEE5applyES5_
_ZN5doris12PositiveImplIdE5applyEd
Line
Count
Source
330
29
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
331
29
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a);
332
29
    }
_ZN5doris12PositiveImplIlE5applyEl
Line
Count
Source
330
31
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
331
31
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a);
332
31
    }
333
};
334
335
struct NamePositive {
336
    static constexpr auto name = "positive";
337
};
338
339
using FunctionPositiveDouble =
340
        FunctionUnaryArithmetic<PositiveImpl<double>, NamePositive, TYPE_DOUBLE>;
341
using FunctionPositiveBigInt =
342
        FunctionUnaryArithmetic<PositiveImpl<Int64>, NamePositive, TYPE_BIGINT>;
343
using FunctionPositiveDecimalV2 =
344
        FunctionUnaryArithmetic<PositiveImpl<DecimalV2Value>, NamePositive, TYPE_DECIMALV2>;
345
using FunctionPositiveDecimal256 =
346
        FunctionUnaryArithmetic<PositiveImpl<Decimal256>, NamePositive, TYPE_DECIMAL256>;
347
using FunctionPositiveDecimalV3 =
348
        FunctionUnaryArithmetic<PositiveImpl<Decimal128V3>, NamePositive, TYPE_DECIMAL128I>;
349
using FunctionPositiveDecimal32 =
350
        FunctionUnaryArithmetic<PositiveImpl<Decimal32>, NamePositive, TYPE_DECIMAL32>;
351
using FunctionPositiveDecimal64 =
352
        FunctionUnaryArithmetic<PositiveImpl<Decimal64>, NamePositive, TYPE_DECIMAL64>;
353
354
struct SinName {
355
    static constexpr auto name = "sin";
356
};
357
using FunctionSin = FunctionMathUnary<UnaryFunctionPlain<SinName, std::sin>>;
358
359
struct SinhName {
360
    static constexpr auto name = "sinh";
361
};
362
using FunctionSinh = FunctionMathUnary<UnaryFunctionPlain<SinhName, std::sinh>>;
363
364
struct SqrtName {
365
    static constexpr auto name = "sqrt";
366
    // https://dev.mysql.com/doc/refman/8.4/en/mathematical-functions.html#function_sqrt
367
115
    static constexpr bool is_invalid_input(Float64 x) { return x < 0; }
368
};
369
using FunctionSqrt =
370
        FunctionMathUnaryAlwayNullable<UnaryFunctionPlainAlwayNullable<SqrtName, std::sqrt>>;
371
372
struct CbrtName {
373
    static constexpr auto name = "cbrt";
374
};
375
using FunctionCbrt = FunctionMathUnary<UnaryFunctionPlain<CbrtName, std::cbrt>>;
376
377
struct TanName {
378
    static constexpr auto name = "tan";
379
};
380
using FunctionTan = FunctionMathUnary<UnaryFunctionPlain<TanName, std::tan>>;
381
382
struct TanhName {
383
    static constexpr auto name = "tanh";
384
};
385
using FunctionTanh = FunctionMathUnary<UnaryFunctionPlain<TanhName, std::tanh>>;
386
387
struct CotName {
388
    static constexpr auto name = "cot";
389
};
390
19
double cot(double x) {
391
19
    return 1.0 / std::tan(x);
392
19
}
393
using FunctionCot = FunctionMathUnary<UnaryFunctionPlain<CotName, cot>>;
394
395
struct SecName {
396
    static constexpr auto name = "sec";
397
};
398
19
double sec(double x) {
399
19
    return 1.0 / std::cos(x);
400
19
}
401
using FunctionSec = FunctionMathUnary<UnaryFunctionPlain<SecName, sec>>;
402
403
struct CscName {
404
    static constexpr auto name = "csc";
405
};
406
20
double csc(double x) {
407
20
    return 1.0 / std::sin(x);
408
20
}
409
using FunctionCosec = FunctionMathUnary<UnaryFunctionPlain<CscName, csc>>;
410
411
static const Int64 FACT_TABLE[] = {1LL,
412
                                   1LL,
413
                                   2LL,
414
                                   6LL,
415
                                   24LL,
416
                                   120LL,
417
                                   720LL,
418
                                   5040LL,
419
                                   40320LL,
420
                                   362880LL,
421
                                   3628800LL,
422
                                   39916800LL,
423
                                   479001600LL,
424
                                   6227020800LL,
425
                                   87178291200LL,
426
                                   1307674368000LL,
427
                                   20922789888000LL,
428
                                   355687428096000LL,
429
                                   6402373705728000LL,
430
                                   121645100408832000LL,
431
                                   2432902008176640000LL};
432
433
class FunctionFactorial : public IFunction {
434
public:
435
    static constexpr auto name = "factorial";
436
34
    static FunctionPtr create() { return std::make_shared<FunctionFactorial>(); }
437
438
private:
439
1
    String get_name() const override { return name; }
440
25
    size_t get_number_of_arguments() const override { return 1; }
441
442
25
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
443
25
        return make_nullable(std::make_shared<DataTypeInt64>());
444
25
    }
445
446
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
447
30
                        uint32_t result, size_t input_rows_count) const override {
448
30
        const auto* data_col =
449
30
                check_and_get_column<ColumnInt64>(block.get_by_position(arguments[0]).column.get());
450
30
        if (!data_col) {
451
0
            return Status::InternalError(
452
0
                    "Unexpected column '%s' for argument of function %s",
453
0
                    block.get_by_position(arguments[0]).column->get_name().c_str(), get_name());
454
0
        }
455
456
30
        auto result_column = ColumnInt64::create(input_rows_count);
457
30
        auto result_null_map = ColumnUInt8::create(input_rows_count, 0);
458
30
        auto& result_data = result_column->get_data();
459
30
        auto& result_null_map_data = result_null_map->get_data();
460
461
30
        const auto& src_data = data_col->get_data();
462
66
        for (size_t i = 0; i < input_rows_count; ++i) {
463
36
            Int64 n = src_data[i];
464
36
            if (n < 0 || n > 20) {
465
15
                result_null_map_data[i] = 1;
466
15
                result_data[i] = 0;
467
21
            } else {
468
21
                result_data[i] = FACT_TABLE[n];
469
21
            }
470
36
        }
471
472
30
        block.replace_by_position(result, ColumnNullable::create(std::move(result_column),
473
30
                                                                 std::move(result_null_map)));
474
475
30
        return Status::OK();
476
30
    }
477
};
478
479
template <typename A>
480
struct RadiansImpl {
481
    static constexpr PrimitiveType ResultType = TYPE_DOUBLE;
482
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
483
29
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
484
29
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a / 180.0 *
485
29
                                                                              PiImpl::value);
486
29
    }
487
};
488
489
struct NameRadians {
490
    static constexpr auto name = "radians";
491
};
492
493
using FunctionRadians = FunctionUnaryArithmetic<RadiansImpl<double>, NameRadians, TYPE_DOUBLE>;
494
495
template <typename A>
496
struct DegreesImpl {
497
    static constexpr PrimitiveType ResultType = TYPE_DOUBLE;
498
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
499
29
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
500
29
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a * 180.0 /
501
29
                                                                              PiImpl::value);
502
29
    }
503
};
504
505
struct NameDegrees {
506
    static constexpr auto name = "degrees";
507
};
508
509
using FunctionDegrees = FunctionUnaryArithmetic<DegreesImpl<double>, NameDegrees, TYPE_DOUBLE>;
510
511
struct NameBin {
512
    static constexpr auto name = "bin";
513
};
514
struct BinImpl {
515
    using ReturnType = DataTypeString;
516
    static constexpr auto PrimitiveTypeImpl = PrimitiveType::TYPE_BIGINT;
517
    using Type = Int64;
518
    using ReturnColumnType = ColumnString;
519
520
549
    static std::string bin_impl(Int64 value) {
521
549
        auto n = static_cast<uint64_t>(value);
522
549
        const size_t max_bits = sizeof(uint64_t) * 8;
523
549
        char result[max_bits];
524
549
        uint32_t index = max_bits;
525
1.46k
        do {
526
1.46k
            result[--index] = '0' + (n & 1);
527
1.46k
        } while (n >>= 1);
528
549
        return std::string(result + index, max_bits - index);
529
549
    }
530
531
    static Status vector(const ColumnInt64::Container& data, ColumnString::Chars& res_data,
532
218
                         ColumnString::Offsets& res_offsets) {
533
218
        res_offsets.resize(data.size());
534
218
        size_t input_size = res_offsets.size();
535
536
767
        for (size_t i = 0; i < input_size; ++i) {
537
549
            StringOP::push_value_string(bin_impl(data[i]), i, res_data, res_offsets);
538
549
        }
539
218
        return Status::OK();
540
218
    }
541
};
542
543
using FunctionBin = FunctionUnaryToType<BinImpl, NameBin>;
544
545
struct PowImpl {
546
    static constexpr PrimitiveType type = TYPE_DOUBLE;
547
    static constexpr auto name = "pow";
548
    static constexpr bool need_replace_null_data_to_default = true;
549
    static constexpr bool is_nullable = false;
550
225
    static inline double apply(double a, double b) { return std::pow(a, b); }
551
};
552
struct LogImpl {
553
    static constexpr PrimitiveType type = TYPE_DOUBLE;
554
    static constexpr auto name = "log";
555
    static constexpr bool need_replace_null_data_to_default = false;
556
    static constexpr bool is_nullable = true;
557
    static constexpr double EPSILON = 1e-9;
558
31
    static inline double apply(double a, double b, UInt8& is_null) {
559
31
        is_null = a <= 0 || b <= 0 || std::fabs(a - 1.0) < EPSILON;
560
31
        return std::log(b) / std::log(a);
561
31
    }
562
};
563
struct Atan2Impl {
564
    static constexpr PrimitiveType type = TYPE_DOUBLE;
565
    static constexpr auto name = "atan2";
566
    static constexpr bool need_replace_null_data_to_default = false;
567
    static constexpr bool is_nullable = false;
568
413
    static inline double apply(double a, double b) { return std::atan2(a, b); }
569
};
570
571
template <typename Impl>
572
class FunctionMathBinary : public IFunction {
573
public:
574
    using cpp_type = typename PrimitiveTypeTraits<Impl::type>::CppType;
575
    using column_type = typename PrimitiveTypeTraits<Impl::type>::ColumnType;
576
577
    static constexpr auto name = Impl::name;
578
    static constexpr bool has_variadic_argument =
579
            !std::is_void_v<decltype(has_variadic_argument_types(std::declval<Impl>()))>;
580
581
3
    String get_name() const override { return name; }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE8get_nameB5cxx11Ev
Line
Count
Source
581
1
    String get_name() const override { return name; }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE8get_nameB5cxx11Ev
Line
Count
Source
581
1
    String get_name() const override { return name; }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE8get_nameB5cxx11Ev
Line
Count
Source
581
1
    String get_name() const override { return name; }
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE8get_nameB5cxx11Ev
582
583
218
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LogImplEE6createEv
Line
Count
Source
583
19
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7PowImplEE6createEv
Line
Count
Source
583
43
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_9Atan2ImplEE6createEv
Line
Count
Source
583
46
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE6createEv
Line
Count
Source
583
14
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE6createEv
Line
Count
Source
583
12
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
584
585
122
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE11is_variadicEv
Line
Count
Source
585
11
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE11is_variadicEv
Line
Count
Source
585
35
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE11is_variadicEv
Line
Count
Source
585
38
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE11is_variadicEv
Line
Count
Source
585
6
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE11is_variadicEv
Line
Count
Source
585
4
    bool is_variadic() const override { return has_variadic_argument; }
586
587
96
    DataTypes get_variadic_argument_types_impl() const override {
588
96
        if constexpr (has_variadic_argument) {
589
72
            return Impl::get_variadic_argument_types();
590
72
        }
591
0
        return {};
592
96
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
        if constexpr (has_variadic_argument) {
589
            return Impl::get_variadic_argument_types();
590
        }
591
8
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
        if constexpr (has_variadic_argument) {
589
            return Impl::get_variadic_argument_types();
590
        }
591
8
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
        if constexpr (has_variadic_argument) {
589
            return Impl::get_variadic_argument_types();
590
        }
591
8
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
8
    DataTypes get_variadic_argument_types_impl() const override {
588
8
        if constexpr (has_variadic_argument) {
589
8
            return Impl::get_variadic_argument_types();
590
8
        }
591
0
        return {};
592
8
    }
593
594
110
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
110
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
110
        return Impl::is_nullable ? make_nullable(res) : res;
597
110
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
594
10
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
10
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
10
        return Impl::is_nullable ? make_nullable(res) : res;
597
10
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
594
34
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
34
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
34
        return Impl::is_nullable ? make_nullable(res) : res;
597
34
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
594
37
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
37
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
37
        return Impl::is_nullable ? make_nullable(res) : res;
597
37
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
5
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
5
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
5
        return Impl::is_nullable ? make_nullable(res) : res;
597
5
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
3
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
3
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
3
        return Impl::is_nullable ? make_nullable(res) : res;
597
3
    }
598
156
    bool need_replace_null_data_to_default() const override {
599
156
        return Impl::need_replace_null_data_to_default;
600
156
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
32
    bool need_replace_null_data_to_default() const override {
599
32
        return Impl::need_replace_null_data_to_default;
600
32
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
66
    bool need_replace_null_data_to_default() const override {
599
66
        return Impl::need_replace_null_data_to_default;
600
66
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
13
    bool need_replace_null_data_to_default() const override {
599
13
        return Impl::need_replace_null_data_to_default;
600
13
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE33need_replace_null_data_to_defaultEv
Line
Count
Source
598
5
    bool need_replace_null_data_to_default() const override {
599
5
        return Impl::need_replace_null_data_to_default;
600
5
    }
601
602
81
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE23get_number_of_argumentsEv
Line
Count
Source
602
10
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE23get_number_of_argumentsEv
Line
Count
Source
602
34
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE23get_number_of_argumentsEv
Line
Count
Source
602
37
    size_t get_number_of_arguments() const override { return 2; }
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE23get_number_of_argumentsEv
603
604
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
605
247
                        uint32_t result, size_t input_rows_count) const override {
606
247
        auto& column_left = block.get_by_position(arguments[0]).column;
607
247
        auto& column_right = block.get_by_position(arguments[1]).column;
608
247
        bool is_const_left = is_column_const(*column_left);
609
247
        bool is_const_right = is_column_const(*column_right);
610
611
247
        ColumnPtr column_result = nullptr;
612
613
18.4E
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
247
        if (is_const_left) {
615
14
            column_result = constant_vector(column_left, column_right);
616
233
        } else if (is_const_right) {
617
30
            column_result = vector_constant(column_left, column_right);
618
203
        } else {
619
203
            column_result = vector_vector(column_left, column_right);
620
203
        }
621
247
        block.replace_by_position(result, std::move(column_result));
622
623
247
        return Status::OK();
624
247
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
56
                        uint32_t result, size_t input_rows_count) const override {
606
56
        auto& column_left = block.get_by_position(arguments[0]).column;
607
56
        auto& column_right = block.get_by_position(arguments[1]).column;
608
56
        bool is_const_left = is_column_const(*column_left);
609
56
        bool is_const_right = is_column_const(*column_right);
610
611
56
        ColumnPtr column_result = nullptr;
612
613
56
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
56
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
56
        } else if (is_const_right) {
617
15
            column_result = vector_constant(column_left, column_right);
618
41
        } else {
619
41
            column_result = vector_vector(column_left, column_right);
620
41
        }
621
56
        block.replace_by_position(result, std::move(column_result));
622
623
56
        return Status::OK();
624
56
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
94
                        uint32_t result, size_t input_rows_count) const override {
606
94
        auto& column_left = block.get_by_position(arguments[0]).column;
607
94
        auto& column_right = block.get_by_position(arguments[1]).column;
608
94
        bool is_const_left = is_column_const(*column_left);
609
94
        bool is_const_right = is_column_const(*column_right);
610
611
94
        ColumnPtr column_result = nullptr;
612
613
94
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
94
        if (is_const_left) {
615
14
            column_result = constant_vector(column_left, column_right);
616
80
        } else if (is_const_right) {
617
15
            column_result = vector_constant(column_left, column_right);
618
65
        } else {
619
65
            column_result = vector_vector(column_left, column_right);
620
65
        }
621
94
        block.replace_by_position(result, std::move(column_result));
622
623
94
        return Status::OK();
624
94
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
17
                        uint32_t result, size_t input_rows_count) const override {
606
17
        auto& column_left = block.get_by_position(arguments[0]).column;
607
17
        auto& column_right = block.get_by_position(arguments[1]).column;
608
17
        bool is_const_left = is_column_const(*column_left);
609
17
        bool is_const_right = is_column_const(*column_right);
610
611
17
        ColumnPtr column_result = nullptr;
612
613
17
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
17
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
17
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
17
        } else {
619
17
            column_result = vector_vector(column_left, column_right);
620
17
        }
621
17
        block.replace_by_position(result, std::move(column_result));
622
623
17
        return Status::OK();
624
17
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
9
                        uint32_t result, size_t input_rows_count) const override {
606
9
        auto& column_left = block.get_by_position(arguments[0]).column;
607
9
        auto& column_right = block.get_by_position(arguments[1]).column;
608
9
        bool is_const_left = is_column_const(*column_left);
609
9
        bool is_const_right = is_column_const(*column_right);
610
611
9
        ColumnPtr column_result = nullptr;
612
613
9
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
9
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
9
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
9
        } else {
619
9
            column_result = vector_vector(column_left, column_right);
620
9
        }
621
9
        block.replace_by_position(result, std::move(column_result));
622
623
9
        return Status::OK();
624
9
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
8
                        uint32_t result, size_t input_rows_count) const override {
606
8
        auto& column_left = block.get_by_position(arguments[0]).column;
607
8
        auto& column_right = block.get_by_position(arguments[1]).column;
608
8
        bool is_const_left = is_column_const(*column_left);
609
8
        bool is_const_right = is_column_const(*column_right);
610
611
8
        ColumnPtr column_result = nullptr;
612
613
18.4E
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
8
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
8
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
8
        } else {
619
8
            column_result = vector_vector(column_left, column_right);
620
8
        }
621
8
        block.replace_by_position(result, std::move(column_result));
622
623
8
        return Status::OK();
624
8
    }
625
626
private:
627
30
    ColumnPtr vector_constant(ColumnPtr column_left, ColumnPtr column_right) const {
628
30
        const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get());
629
30
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left.get());
630
30
        auto column_result = column_type::create(column_left->size());
631
632
30
        if constexpr (Impl::is_nullable) {
633
0
            auto null_map = ColumnUInt8::create(column_left->size(), 0);
634
0
            auto& a = column_left_ptr->get_data();
635
0
            auto& c = column_result->get_data();
636
0
            auto& n = null_map->get_data();
637
0
            size_t size = a.size();
638
0
            for (size_t i = 0; i < size; ++i) {
639
0
                c[i] = Impl::apply(a[i], column_right_ptr->template get_value<Impl::type>(), n[i]);
640
0
            }
641
0
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
642
30
        } else {
643
30
            auto& a = column_left_ptr->get_data();
644
30
            auto& c = column_result->get_data();
645
30
            size_t size = a.size();
646
160
            for (size_t i = 0; i < size; ++i) {
647
130
                c[i] = Impl::apply(a[i], column_right_ptr->template get_value<Impl::type>());
648
130
            }
649
30
            return column_result;
650
30
        }
651
30
    }
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LogImplEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
627
15
    ColumnPtr vector_constant(ColumnPtr column_left, ColumnPtr column_right) const {
628
15
        const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get());
629
15
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left.get());
630
15
        auto column_result = column_type::create(column_left->size());
631
632
        if constexpr (Impl::is_nullable) {
633
            auto null_map = ColumnUInt8::create(column_left->size(), 0);
634
            auto& a = column_left_ptr->get_data();
635
            auto& c = column_result->get_data();
636
            auto& n = null_map->get_data();
637
            size_t size = a.size();
638
            for (size_t i = 0; i < size; ++i) {
639
                c[i] = Impl::apply(a[i], column_right_ptr->template get_value<Impl::type>(), n[i]);
640
            }
641
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
642
15
        } else {
643
15
            auto& a = column_left_ptr->get_data();
644
15
            auto& c = column_result->get_data();
645
15
            size_t size = a.size();
646
128
            for (size_t i = 0; i < size; ++i) {
647
113
                c[i] = Impl::apply(a[i], column_right_ptr->template get_value<Impl::type>());
648
113
            }
649
15
            return column_result;
650
15
        }
651
15
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
627
15
    ColumnPtr vector_constant(ColumnPtr column_left, ColumnPtr column_right) const {
628
15
        const auto* column_right_ptr = assert_cast<const ColumnConst*>(column_right.get());
629
15
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left.get());
630
15
        auto column_result = column_type::create(column_left->size());
631
632
        if constexpr (Impl::is_nullable) {
633
            auto null_map = ColumnUInt8::create(column_left->size(), 0);
634
            auto& a = column_left_ptr->get_data();
635
            auto& c = column_result->get_data();
636
            auto& n = null_map->get_data();
637
            size_t size = a.size();
638
            for (size_t i = 0; i < size; ++i) {
639
                c[i] = Impl::apply(a[i], column_right_ptr->template get_value<Impl::type>(), n[i]);
640
            }
641
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
642
15
        } else {
643
15
            auto& a = column_left_ptr->get_data();
644
15
            auto& c = column_result->get_data();
645
15
            size_t size = a.size();
646
32
            for (size_t i = 0; i < size; ++i) {
647
17
                c[i] = Impl::apply(a[i], column_right_ptr->template get_value<Impl::type>());
648
17
            }
649
15
            return column_result;
650
15
        }
651
15
    }
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE15vector_constantENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
652
653
14
    ColumnPtr constant_vector(ColumnPtr column_left, ColumnPtr column_right) const {
654
14
        const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get());
655
656
14
        const auto* column_right_ptr = assert_cast<const column_type*>(column_right.get());
657
14
        auto column_result = column_type::create(column_right->size());
658
659
14
        if constexpr (Impl::is_nullable) {
660
0
            auto null_map = ColumnUInt8::create(column_right->size(), 0);
661
0
            auto& b = column_right_ptr->get_data();
662
0
            auto& c = column_result->get_data();
663
0
            auto& n = null_map->get_data();
664
0
            size_t size = b.size();
665
0
            for (size_t i = 0; i < size; ++i) {
666
0
                c[i] = Impl::apply(column_left_ptr->template get_value<Impl::type>(), b[i], n[i]);
667
0
            }
668
0
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
669
14
        } else {
670
14
            auto& b = column_right_ptr->get_data();
671
14
            auto& c = column_result->get_data();
672
14
            size_t size = b.size();
673
30
            for (size_t i = 0; i < size; ++i) {
674
16
                c[i] = Impl::apply(column_left_ptr->template get_value<Impl::type>(), b[i]);
675
16
            }
676
14
            return column_result;
677
14
        }
678
14
    }
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LogImplEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7PowImplEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
653
14
    ColumnPtr constant_vector(ColumnPtr column_left, ColumnPtr column_right) const {
654
14
        const auto* column_left_ptr = assert_cast<const ColumnConst*>(column_left.get());
655
656
14
        const auto* column_right_ptr = assert_cast<const column_type*>(column_right.get());
657
14
        auto column_result = column_type::create(column_right->size());
658
659
        if constexpr (Impl::is_nullable) {
660
            auto null_map = ColumnUInt8::create(column_right->size(), 0);
661
            auto& b = column_right_ptr->get_data();
662
            auto& c = column_result->get_data();
663
            auto& n = null_map->get_data();
664
            size_t size = b.size();
665
            for (size_t i = 0; i < size; ++i) {
666
                c[i] = Impl::apply(column_left_ptr->template get_value<Impl::type>(), b[i], n[i]);
667
            }
668
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
669
14
        } else {
670
14
            auto& b = column_right_ptr->get_data();
671
14
            auto& c = column_result->get_data();
672
14
            size_t size = b.size();
673
30
            for (size_t i = 0; i < size; ++i) {
674
16
                c[i] = Impl::apply(column_left_ptr->template get_value<Impl::type>(), b[i]);
675
16
            }
676
14
            return column_result;
677
14
        }
678
14
    }
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Unexecuted instantiation: _ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE15constant_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
679
680
202
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
202
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
202
        const auto* column_right_ptr =
683
202
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
202
        auto column_result = column_type::create(column_left->size());
686
687
202
        if constexpr (Impl::is_nullable) {
688
9
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
9
            auto& a = column_left_ptr->get_data();
690
9
            auto& b = column_right_ptr->get_data();
691
9
            auto& c = column_result->get_data();
692
9
            auto& n = null_map->get_data();
693
9
            size_t size = a.size();
694
40
            for (size_t i = 0; i < size; ++i) {
695
31
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
31
            }
697
9
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
193
        } else {
699
193
            auto& a = column_left_ptr->get_data();
700
193
            auto& b = column_right_ptr->get_data();
701
193
            auto& c = column_result->get_data();
702
193
            size_t size = a.size();
703
969
            for (size_t i = 0; i < size; ++i) {
704
776
                c[i] = Impl::apply(a[i], b[i]);
705
776
            }
706
193
            return column_result;
707
193
        }
708
202
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
9
        if constexpr (Impl::is_nullable) {
688
9
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
9
            auto& a = column_left_ptr->get_data();
690
9
            auto& b = column_right_ptr->get_data();
691
9
            auto& c = column_result->get_data();
692
9
            auto& n = null_map->get_data();
693
9
            size_t size = a.size();
694
40
            for (size_t i = 0; i < size; ++i) {
695
31
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
31
            }
697
9
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
        } else {
699
            auto& a = column_left_ptr->get_data();
700
            auto& b = column_right_ptr->get_data();
701
            auto& c = column_result->get_data();
702
            size_t size = a.size();
703
            for (size_t i = 0; i < size; ++i) {
704
                c[i] = Impl::apply(a[i], b[i]);
705
            }
706
            return column_result;
707
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
680
40
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
40
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
40
        const auto* column_right_ptr =
683
40
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
40
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
40
        } else {
699
40
            auto& a = column_left_ptr->get_data();
700
40
            auto& b = column_right_ptr->get_data();
701
40
            auto& c = column_result->get_data();
702
40
            size_t size = a.size();
703
152
            for (size_t i = 0; i < size; ++i) {
704
112
                c[i] = Impl::apply(a[i], b[i]);
705
112
            }
706
40
            return column_result;
707
40
        }
708
40
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
680
65
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
65
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
65
        const auto* column_right_ptr =
683
65
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
65
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
65
        } else {
699
65
            auto& a = column_left_ptr->get_data();
700
65
            auto& b = column_right_ptr->get_data();
701
65
            auto& c = column_result->get_data();
702
65
            size_t size = a.size();
703
445
            for (size_t i = 0; i < size; ++i) {
704
380
                c[i] = Impl::apply(a[i], b[i]);
705
380
            }
706
65
            return column_result;
707
65
        }
708
65
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
9
        } else {
699
9
            auto& a = column_left_ptr->get_data();
700
9
            auto& b = column_right_ptr->get_data();
701
9
            auto& c = column_result->get_data();
702
9
            size_t size = a.size();
703
40
            for (size_t i = 0; i < size; ++i) {
704
31
                c[i] = Impl::apply(a[i], b[i]);
705
31
            }
706
9
            return column_result;
707
9
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
9
        } else {
699
9
            auto& a = column_left_ptr->get_data();
700
9
            auto& b = column_right_ptr->get_data();
701
9
            auto& c = column_result->get_data();
702
9
            size_t size = a.size();
703
36
            for (size_t i = 0; i < size; ++i) {
704
27
                c[i] = Impl::apply(a[i], b[i]);
705
27
            }
706
9
            return column_result;
707
9
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
9
        } else {
699
9
            auto& a = column_left_ptr->get_data();
700
9
            auto& b = column_right_ptr->get_data();
701
9
            auto& c = column_result->get_data();
702
9
            size_t size = a.size();
703
42
            for (size_t i = 0; i < size; ++i) {
704
33
                c[i] = Impl::apply(a[i], b[i]);
705
33
            }
706
9
            return column_result;
707
9
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
9
        } else {
699
9
            auto& a = column_left_ptr->get_data();
700
9
            auto& b = column_right_ptr->get_data();
701
9
            auto& c = column_result->get_data();
702
9
            size_t size = a.size();
703
36
            for (size_t i = 0; i < size; ++i) {
704
27
                c[i] = Impl::apply(a[i], b[i]);
705
27
            }
706
9
            return column_result;
707
9
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
9
        } else {
699
9
            auto& a = column_left_ptr->get_data();
700
9
            auto& b = column_right_ptr->get_data();
701
9
            auto& c = column_result->get_data();
702
9
            size_t size = a.size();
703
36
            for (size_t i = 0; i < size; ++i) {
704
27
                c[i] = Impl::apply(a[i], b[i]);
705
27
            }
706
9
            return column_result;
707
9
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
17
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
17
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
17
        const auto* column_right_ptr =
683
17
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
17
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
17
        } else {
699
17
            auto& a = column_left_ptr->get_data();
700
17
            auto& b = column_right_ptr->get_data();
701
17
            auto& c = column_result->get_data();
702
17
            size_t size = a.size();
703
69
            for (size_t i = 0; i < size; ++i) {
704
52
                c[i] = Impl::apply(a[i], b[i]);
705
52
            }
706
17
            return column_result;
707
17
        }
708
17
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
9
        } else {
699
9
            auto& a = column_left_ptr->get_data();
700
9
            auto& b = column_right_ptr->get_data();
701
9
            auto& c = column_result->get_data();
702
9
            size_t size = a.size();
703
42
            for (size_t i = 0; i < size; ++i) {
704
33
                c[i] = Impl::apply(a[i], b[i]);
705
33
            }
706
9
            return column_result;
707
9
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
9
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
9
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
9
        const auto* column_right_ptr =
683
9
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
9
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
9
        } else {
699
9
            auto& a = column_left_ptr->get_data();
700
9
            auto& b = column_right_ptr->get_data();
701
9
            auto& c = column_result->get_data();
702
9
            size_t size = a.size();
703
36
            for (size_t i = 0; i < size; ++i) {
704
27
                c[i] = Impl::apply(a[i], b[i]);
705
27
            }
706
9
            return column_result;
707
9
        }
708
9
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
8
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
8
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
8
        const auto* column_right_ptr =
683
8
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
8
        auto column_result = column_type::create(column_left->size());
686
687
        if constexpr (Impl::is_nullable) {
688
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
            auto& a = column_left_ptr->get_data();
690
            auto& b = column_right_ptr->get_data();
691
            auto& c = column_result->get_data();
692
            auto& n = null_map->get_data();
693
            size_t size = a.size();
694
            for (size_t i = 0; i < size; ++i) {
695
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
            }
697
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
8
        } else {
699
8
            auto& a = column_left_ptr->get_data();
700
8
            auto& b = column_right_ptr->get_data();
701
8
            auto& c = column_result->get_data();
702
8
            size_t size = a.size();
703
35
            for (size_t i = 0; i < size; ++i) {
704
27
                c[i] = Impl::apply(a[i], b[i]);
705
27
            }
706
8
            return column_result;
707
8
        }
708
8
    }
709
};
710
711
class FunctionNormalCdf : public IFunction {
712
public:
713
    static constexpr auto name = "normal_cdf";
714
715
1
    String get_name() const override { return name; }
716
717
40
    static FunctionPtr create() { return std::make_shared<FunctionNormalCdf>(); }
718
719
31
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
720
31
        return make_nullable(std::make_shared<DataTypeFloat64>());
721
31
    }
722
723
8
    DataTypes get_variadic_argument_types_impl() const override {
724
8
        return {std::make_shared<DataTypeFloat64>(), std::make_shared<DataTypeFloat64>(),
725
8
                std::make_shared<DataTypeFloat64>()};
726
8
    }
727
31
    size_t get_number_of_arguments() const override { return 3; }
728
729
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
730
72
                        uint32_t result, size_t input_rows_count) const override {
731
72
        auto result_column = ColumnFloat64::create(input_rows_count);
732
72
        auto result_null_map_column = ColumnUInt8::create(input_rows_count, 0);
733
734
72
        auto& result_data = result_column->get_data();
735
72
        NullMap& result_null_map =
736
72
                assert_cast<ColumnUInt8*>(result_null_map_column.get())->get_data();
737
738
72
        ColumnPtr argument_columns[3];
739
72
        bool col_const[3];
740
72
        size_t argument_size = arguments.size();
741
288
        for (int i = 0; i < argument_size; ++i) {
742
216
            argument_columns[i] = block.get_by_position(arguments[i]).column;
743
216
            col_const[i] = is_column_const(*argument_columns[i]);
744
216
            if (col_const[i]) {
745
82
                argument_columns[i] =
746
82
                        static_cast<const ColumnConst&>(*argument_columns[i]).get_data_column_ptr();
747
82
            }
748
216
        }
749
750
72
        const auto* mean_col = assert_cast<const ColumnFloat64*>(argument_columns[0].get());
751
72
        const auto* sd_col = assert_cast<const ColumnFloat64*>(argument_columns[1].get());
752
72
        const auto* value_col = assert_cast<const ColumnFloat64*>(argument_columns[2].get());
753
754
72
        result_column->reserve(input_rows_count);
755
261
        for (size_t i = 0; i < input_rows_count; ++i) {
756
189
            double mean = mean_col->get_element(index_check_const(i, col_const[0]));
757
189
            double sd = sd_col->get_element(index_check_const(i, col_const[1]));
758
189
            double v = value_col->get_element(index_check_const(i, col_const[2]));
759
760
189
            if (!check_argument(sd)) [[unlikely]] {
761
35
                result_null_map[i] = true;
762
35
                continue;
763
35
            }
764
154
            result_data[i] = calculate_cell(mean, sd, v);
765
154
        }
766
767
72
        block.get_by_position(result).column =
768
72
                ColumnNullable::create(std::move(result_column), std::move(result_null_map_column));
769
72
        return Status::OK();
770
72
    }
771
772
189
    static bool check_argument(double sd) { return sd > 0; }
773
154
    static double calculate_cell(double mean, double sd, double v) {
774
#ifdef __APPLE__
775
        const double sqrt2 = std::sqrt(2);
776
#else
777
154
        constexpr double sqrt2 = std::numbers::sqrt2;
778
154
#endif
779
780
154
        return 0.5 * (std::erf((v - mean) / (sd * sqrt2)) + 1);
781
154
    }
782
};
783
784
template <typename A>
785
struct SignBitImpl {
786
    static constexpr PrimitiveType ResultType = TYPE_BOOLEAN;
787
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
788
31
    static inline bool apply(A a) { return std::signbit(static_cast<Float64>(a)); }
789
};
790
791
struct NameSignBit {
792
    static constexpr auto name = "signbit";
793
};
794
795
using FunctionSignBit = FunctionUnaryArithmetic<SignBitImpl<double>, NameSignBit, TYPE_DOUBLE>;
796
797
34
double EvenImpl(double a) {
798
34
    double mag = std::abs(a);
799
34
    double even_mag = 2 * std::ceil(mag / 2);
800
34
    return std::copysign(even_mag, a);
801
34
}
802
803
struct NameEven {
804
    static constexpr auto name = "even";
805
};
806
807
using FunctionEven = FunctionMathUnary<UnaryFunctionPlain<NameEven, EvenImpl>>;
808
809
template <PrimitiveType A>
810
struct GcdImpl {
811
    using cpp_type = typename PrimitiveTypeTraits<A>::CppType;
812
813
    static constexpr PrimitiveType type = A;
814
    static constexpr auto name = "gcd";
815
    static constexpr bool need_replace_null_data_to_default = false;
816
    static constexpr bool is_nullable = false;
817
818
40
    static DataTypes get_variadic_argument_types() {
819
40
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
40
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
40
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE3EE27get_variadic_argument_typesEv
Line
Count
Source
818
8
    static DataTypes get_variadic_argument_types() {
819
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
8
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE4EE27get_variadic_argument_typesEv
Line
Count
Source
818
8
    static DataTypes get_variadic_argument_types() {
819
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
8
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE5EE27get_variadic_argument_typesEv
Line
Count
Source
818
8
    static DataTypes get_variadic_argument_types() {
819
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
8
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE6EE27get_variadic_argument_typesEv
Line
Count
Source
818
8
    static DataTypes get_variadic_argument_types() {
819
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
8
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE7EE27get_variadic_argument_typesEv
Line
Count
Source
818
8
    static DataTypes get_variadic_argument_types() {
819
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
8
    }
822
823
145
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
145
        return static_cast<cpp_type>(std::gcd(a, b));
825
145
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE3EE5applyEaa
Line
Count
Source
823
31
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
31
        return static_cast<cpp_type>(std::gcd(a, b));
825
31
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE4EE5applyEss
Line
Count
Source
823
27
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
27
        return static_cast<cpp_type>(std::gcd(a, b));
825
27
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE5EE5applyEii
Line
Count
Source
823
33
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
33
        return static_cast<cpp_type>(std::gcd(a, b));
825
33
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE6EE5applyEll
Line
Count
Source
823
27
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
27
        return static_cast<cpp_type>(std::gcd(a, b));
825
27
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE7EE5applyEnn
Line
Count
Source
823
27
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
27
        return static_cast<cpp_type>(std::gcd(a, b));
825
27
    }
826
};
827
828
template <PrimitiveType A>
829
struct LcmImpl {
830
    using cpp_type = typename PrimitiveTypeTraits<A>::CppType;
831
832
    static constexpr PrimitiveType type = A;
833
    static constexpr auto name = "lcm";
834
    static constexpr bool need_replace_null_data_to_default = false;
835
    static constexpr bool is_nullable = false;
836
837
32
    static DataTypes get_variadic_argument_types() {
838
32
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
32
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
32
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE4EE27get_variadic_argument_typesEv
Line
Count
Source
837
8
    static DataTypes get_variadic_argument_types() {
838
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
8
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE5EE27get_variadic_argument_typesEv
Line
Count
Source
837
8
    static DataTypes get_variadic_argument_types() {
838
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
8
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE6EE27get_variadic_argument_typesEv
Line
Count
Source
837
8
    static DataTypes get_variadic_argument_types() {
838
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
8
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE7EE27get_variadic_argument_typesEv
Line
Count
Source
837
8
    static DataTypes get_variadic_argument_types() {
838
8
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
8
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
8
    }
841
842
139
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
139
        return static_cast<cpp_type>(std::lcm(a, b));
844
139
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE4EE5applyEss
Line
Count
Source
842
52
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
52
        return static_cast<cpp_type>(std::lcm(a, b));
844
52
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE5EE5applyEii
Line
Count
Source
842
33
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
33
        return static_cast<cpp_type>(std::lcm(a, b));
844
33
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE6EE5applyEll
Line
Count
Source
842
27
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
27
        return static_cast<cpp_type>(std::lcm(a, b));
844
27
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE7EE5applyEnn
Line
Count
Source
842
27
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
27
        return static_cast<cpp_type>(std::lcm(a, b));
844
27
    }
845
};
846
847
enum class FloatPointNumberJudgmentType {
848
    IsNan = 0,
849
    IsInf,
850
};
851
852
struct ImplIsNan {
853
    static constexpr auto name = "isnan";
854
    static constexpr FloatPointNumberJudgmentType type = FloatPointNumberJudgmentType::IsNan;
855
};
856
857
struct ImplIsInf {
858
    static constexpr auto name = "isinf";
859
    static constexpr FloatPointNumberJudgmentType type = FloatPointNumberJudgmentType::IsInf;
860
};
861
862
template <typename Impl>
863
class FunctionFloatingPointNumberJudgment : public IFunction {
864
public:
865
    using IFunction::execute;
866
867
    static constexpr auto name = Impl::name;
868
26
    static FunctionPtr create() { return std::make_shared<FunctionFloatingPointNumberJudgment>(); }
_ZN5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE6createEv
Line
Count
Source
868
13
    static FunctionPtr create() { return std::make_shared<FunctionFloatingPointNumberJudgment>(); }
_ZN5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE6createEv
Line
Count
Source
868
13
    static FunctionPtr create() { return std::make_shared<FunctionFloatingPointNumberJudgment>(); }
869
870
private:
871
2
    String get_name() const override { return name; }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE8get_nameB5cxx11Ev
Line
Count
Source
871
1
    String get_name() const override { return name; }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE8get_nameB5cxx11Ev
Line
Count
Source
871
1
    String get_name() const override { return name; }
872
8
    size_t get_number_of_arguments() const override { return 1; }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE23get_number_of_argumentsEv
Line
Count
Source
872
4
    size_t get_number_of_arguments() const override { return 1; }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE23get_number_of_argumentsEv
Line
Count
Source
872
4
    size_t get_number_of_arguments() const override { return 1; }
873
874
8
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
875
8
        return std::make_shared<DataTypeBool>();
876
8
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
874
4
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
875
4
        return std::make_shared<DataTypeBool>();
876
4
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
874
4
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
875
4
        return std::make_shared<DataTypeBool>();
876
4
    }
877
878
    void execute_impl_with_type(const auto* input_column,
879
8
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
40
        for (int i = 0; i < size; i++) {
881
32
            auto value = input_column->get_element(i);
882
32
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
16
                output[i] = std::isnan(value);
884
16
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
16
                output[i] = std::isinf(value);
886
16
            }
887
32
        }
888
8
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE22execute_impl_with_typeINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEEEvPKT_RNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEEm
Line
Count
Source
879
3
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
12
        for (int i = 0; i < size; i++) {
881
9
            auto value = input_column->get_element(i);
882
9
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
9
                output[i] = std::isnan(value);
884
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
                output[i] = std::isinf(value);
886
            }
887
9
        }
888
3
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE22execute_impl_with_typeINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEEvPKT_RNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEEm
Line
Count
Source
879
1
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
8
        for (int i = 0; i < size; i++) {
881
7
            auto value = input_column->get_element(i);
882
7
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
7
                output[i] = std::isnan(value);
884
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
                output[i] = std::isinf(value);
886
            }
887
7
        }
888
1
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE22execute_impl_with_typeINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEEEvPKT_RNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEEm
Line
Count
Source
879
3
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
12
        for (int i = 0; i < size; i++) {
881
9
            auto value = input_column->get_element(i);
882
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
                output[i] = std::isnan(value);
884
9
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
9
                output[i] = std::isinf(value);
886
9
            }
887
9
        }
888
3
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE22execute_impl_with_typeINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEEvPKT_RNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEEm
Line
Count
Source
879
1
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
8
        for (int i = 0; i < size; i++) {
881
7
            auto value = input_column->get_element(i);
882
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
                output[i] = std::isnan(value);
884
7
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
7
                output[i] = std::isinf(value);
886
7
            }
887
7
        }
888
1
    }
889
890
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
891
8
                        uint32_t result, size_t input_rows_count) const override {
892
8
        auto dst = DataTypeBool::ColumnType::create();
893
8
        auto& dst_data = dst->get_data();
894
8
        dst_data.resize(input_rows_count);
895
8
        const auto* column = block.get_by_position(arguments[0]).column.get();
896
8
        if (const auto* col_f64 = check_and_get_column<ColumnFloat64>(column)) {
897
6
            execute_impl_with_type(col_f64, dst_data, input_rows_count);
898
6
        } else if (const auto* col_f32 = check_and_get_column<ColumnFloat32>(column)) {
899
2
            execute_impl_with_type(col_f32, dst_data, input_rows_count);
900
2
        } else {
901
0
            return Status::InvalidArgument("Unsupported column type  {} for function {}",
902
0
                                           column->get_name(), get_name());
903
0
        }
904
8
        block.replace_by_position(result, std::move(dst));
905
8
        return Status::OK();
906
8
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
891
4
                        uint32_t result, size_t input_rows_count) const override {
892
4
        auto dst = DataTypeBool::ColumnType::create();
893
4
        auto& dst_data = dst->get_data();
894
4
        dst_data.resize(input_rows_count);
895
4
        const auto* column = block.get_by_position(arguments[0]).column.get();
896
4
        if (const auto* col_f64 = check_and_get_column<ColumnFloat64>(column)) {
897
3
            execute_impl_with_type(col_f64, dst_data, input_rows_count);
898
3
        } else if (const auto* col_f32 = check_and_get_column<ColumnFloat32>(column)) {
899
1
            execute_impl_with_type(col_f32, dst_data, input_rows_count);
900
1
        } else {
901
0
            return Status::InvalidArgument("Unsupported column type  {} for function {}",
902
0
                                           column->get_name(), get_name());
903
0
        }
904
4
        block.replace_by_position(result, std::move(dst));
905
4
        return Status::OK();
906
4
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
891
4
                        uint32_t result, size_t input_rows_count) const override {
892
4
        auto dst = DataTypeBool::ColumnType::create();
893
4
        auto& dst_data = dst->get_data();
894
4
        dst_data.resize(input_rows_count);
895
4
        const auto* column = block.get_by_position(arguments[0]).column.get();
896
4
        if (const auto* col_f64 = check_and_get_column<ColumnFloat64>(column)) {
897
3
            execute_impl_with_type(col_f64, dst_data, input_rows_count);
898
3
        } else if (const auto* col_f32 = check_and_get_column<ColumnFloat32>(column)) {
899
1
            execute_impl_with_type(col_f32, dst_data, input_rows_count);
900
1
        } else {
901
0
            return Status::InvalidArgument("Unsupported column type  {} for function {}",
902
0
                                           column->get_name(), get_name());
903
0
        }
904
4
        block.replace_by_position(result, std::move(dst));
905
4
        return Status::OK();
906
4
    }
907
};
908
909
using FunctionIsNan = FunctionFloatingPointNumberJudgment<ImplIsNan>;
910
using FunctionIsInf = FunctionFloatingPointNumberJudgment<ImplIsInf>;
911
912
8
void register_function_math(SimpleFunctionFactory& factory) {
913
8
    factory.register_function<FunctionAcos>();
914
8
    factory.register_function<FunctionAcosh>();
915
8
    factory.register_function<FunctionAsin>();
916
8
    factory.register_function<FunctionAsinh>();
917
8
    factory.register_function<FunctionAtan>();
918
8
    factory.register_function<FunctionAtanh>();
919
8
    factory.register_function<FunctionMathBinary<LogImpl>>();
920
8
    factory.register_function<FunctionMathBinary<PowImpl>>();
921
8
    factory.register_function<FunctionMathBinary<Atan2Impl>>();
922
8
    factory.register_function<FunctionCos>();
923
8
    factory.register_function<FunctionCosh>();
924
8
    factory.register_function<FunctionE>();
925
8
    factory.register_alias("ln", "dlog1");
926
8
    factory.register_function<FunctionMathLog<ImplLn>>();
927
8
    factory.register_function<FunctionMathLog<ImplLog2>>();
928
8
    factory.register_function<FunctionMathLog<ImplLog10>>();
929
8
    factory.register_alias("log10", "dlog10");
930
8
    factory.register_function<FunctionPi>();
931
8
    factory.register_function<FunctionSign>();
932
8
    factory.register_function<FunctionAbsInt8>();
933
8
    factory.register_function<FunctionAbsInt16>();
934
8
    factory.register_function<FunctionAbsInt32>();
935
8
    factory.register_function<FunctionAbsInt64>();
936
8
    factory.register_function<FunctionAbsInt128>();
937
8
    factory.register_function<FunctionAbsUInt8>();
938
8
    factory.register_function<FunctionAbsDecimal32>();
939
8
    factory.register_function<FunctionAbsDecimal64>();
940
8
    factory.register_function<FunctionAbsDecimalV3>();
941
8
    factory.register_function<FunctionAbsDecimalV2>();
942
8
    factory.register_function<FunctionAbsDecimal256>();
943
8
    factory.register_function<FunctionAbsFloat>();
944
8
    factory.register_function<FunctionAbsDouble>();
945
8
    factory.register_function<FunctionNegativeDouble>();
946
8
    factory.register_function<FunctionNegativeBigInt>();
947
8
    factory.register_function<FunctionNegativeDecimalV2>();
948
8
    factory.register_function<FunctionNegativeDecimal256>();
949
8
    factory.register_function<FunctionNegativeDecimalV3>();
950
8
    factory.register_function<FunctionNegativeDecimal32>();
951
8
    factory.register_function<FunctionNegativeDecimal64>();
952
953
8
    factory.register_function<FunctionPositiveDecimal32>();
954
8
    factory.register_function<FunctionPositiveDecimal64>();
955
8
    factory.register_function<FunctionPositiveDecimalV3>();
956
8
    factory.register_function<FunctionPositiveDecimalV2>();
957
8
    factory.register_function<FunctionPositiveDecimal256>();
958
8
    factory.register_function<FunctionPositiveDouble>();
959
8
    factory.register_function<FunctionPositiveBigInt>();
960
961
8
    factory.register_function<FunctionSin>();
962
8
    factory.register_function<FunctionSinh>();
963
8
    factory.register_function<FunctionSqrt>();
964
8
    factory.register_alias("sqrt", "dsqrt");
965
8
    factory.register_function<FunctionCbrt>();
966
8
    factory.register_function<FunctionTan>();
967
8
    factory.register_function<FunctionTanh>();
968
8
    factory.register_function<FunctionCot>();
969
8
    factory.register_function<FunctionSec>();
970
8
    factory.register_function<FunctionCosec>();
971
8
    factory.register_alias("pow", "power");
972
8
    factory.register_alias("pow", "dpow");
973
8
    factory.register_alias("pow", "fpow");
974
8
    factory.register_function<FunctionExp>();
975
8
    factory.register_alias("exp", "dexp");
976
8
    factory.register_function<FunctionFactorial>();
977
8
    factory.register_function<FunctionRadians>();
978
8
    factory.register_function<FunctionDegrees>();
979
8
    factory.register_function<FunctionBin>();
980
8
    factory.register_function<FunctionNormalCdf>();
981
8
    factory.register_function<FunctionSignBit>();
982
8
    factory.register_function<FunctionEven>();
983
8
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_TINYINT>>>();
984
8
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_SMALLINT>>>();
985
8
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_INT>>>();
986
8
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_BIGINT>>>();
987
8
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_LARGEINT>>>();
988
8
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_SMALLINT>>>();
989
8
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_INT>>>();
990
8
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_BIGINT>>>();
991
8
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_LARGEINT>>>();
992
8
    factory.register_function<FunctionIsNan>();
993
8
    factory.register_function<FunctionIsInf>();
994
8
}
995
} // namespace doris