Coverage Report

Created: 2026-03-18 20:04

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
57
    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
35
    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
94
    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
59
    static FunctionPtr create() { return std::make_shared<FunctionAtan>(); }
83
84
0
    String get_name() const override { return name; }
85
53
    bool is_variadic() const override { return true; }
86
0
    size_t get_number_of_arguments() const override { return 0; }
87
88
52
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
89
52
        return std::make_shared<DataTypeFloat64>();
90
52
    }
91
92
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
93
57
                        uint32_t result, size_t input_rows_count) const override {
94
57
        if (arguments.size() == 1) {
95
30
            return execute_unary(block, arguments, result, input_rows_count);
96
30
        } else if (arguments.size() == 2) {
97
27
            return execute_binary(block, arguments, result, input_rows_count);
98
27
        } else {
99
0
            return Status::InvalidArgument("atan function expects 1 or 2 arguments, but got {}",
100
0
                                           arguments.size());
101
0
        }
102
57
    }
103
104
private:
105
    Status execute_unary(Block& block, const ColumnNumbers& arguments, uint32_t result,
106
30
                         size_t input_rows_count) const {
107
30
        auto res_col = ColumnFloat64::create(input_rows_count);
108
30
        auto& res_data = res_col->get_data();
109
110
30
        const auto& col_data =
111
30
                assert_cast<const ColumnFloat64*>(block.get_by_position(arguments[0]).column.get())
112
30
                        ->get_data();
113
108
        for (size_t i = 0; i < input_rows_count; ++i) {
114
78
            res_data[i] = std::atan(col_data[i]);
115
78
        }
116
117
30
        block.replace_by_position(result, std::move(res_col));
118
30
        return Status::OK();
119
30
    }
120
121
    Status execute_binary(Block& block, const ColumnNumbers& arguments, uint32_t result,
122
27
                          size_t input_rows_count) const {
123
27
        auto [col_y, is_const_y] = unpack_if_const(block.get_by_position(arguments[0]).column);
124
27
        auto [col_x, is_const_x] = unpack_if_const(block.get_by_position(arguments[1]).column);
125
126
27
        auto result_column = ColumnFloat64::create(input_rows_count);
127
27
        auto& result_data = result_column->get_data();
128
129
27
        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
26
        } 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
25
        } else {
146
25
            const auto* y_col = assert_cast<const ColumnFloat64*>(col_y.get());
147
25
            const auto* x_col = assert_cast<const ColumnFloat64*>(col_x.get());
148
25
            const auto& y_data = y_col->get_data();
149
25
            const auto& x_data = x_col->get_data();
150
78
            for (size_t i = 0; i < input_rows_count; ++i) {
151
53
                result_data[i] = std::atan2(y_data[i], x_data[i]);
152
53
            }
153
25
        }
154
155
27
        block.replace_by_position(result, std::move(result_column));
156
27
        return Status::OK();
157
27
    }
158
};
159
160
struct AtanhName {
161
    static constexpr auto name = "atanh";
162
50
    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
65
    static inline UInt8 apply(A a) {
199
65
        if constexpr (IsDecimalNumber<A> || std::is_floating_point_v<A>) {
200
65
            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
65
    }
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
11
            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.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
    }
_ZN5doris7AbsImplIsE5applyEs
Line
Count
Source
218
26.3k
    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.3k
        } else if constexpr (IsIntegralV<A>) {
224
26.3k
            return a < A(0) ? static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(~a) + 1
225
26.3k
                            : 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.3k
    }
_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
113
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
        if constexpr (IsDecimal128V2<A>) {
220
            return DecimalV2Value(a < A(0) ? A(-a) : a);
221
113
        } else if constexpr (IsDecimalNumber<A>) {
222
113
            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
113
    }
_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
    }
_ZN5doris7AbsImplINS_14DecimalV2ValueEE5applyES1_
Line
Count
Source
218
11
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
219
11
        if constexpr (IsDecimal128V2<A>) {
220
11
            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
        } 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
11
    }
_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
128
    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
35
double cot(double x) {
391
35
    return 1.0 / std::tan(x);
392
35
}
393
using FunctionCot = FunctionMathUnary<UnaryFunctionPlain<CotName, cot>>;
394
395
struct SecName {
396
    static constexpr auto name = "sec";
397
};
398
35
double sec(double x) {
399
35
    return 1.0 / std::cos(x);
400
35
}
401
using FunctionSec = FunctionMathUnary<UnaryFunctionPlain<SecName, sec>>;
402
403
struct CscName {
404
    static constexpr auto name = "csc";
405
};
406
35
double csc(double x) {
407
35
    return 1.0 / std::sin(x);
408
35
}
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
40
    static FunctionPtr create() { return std::make_shared<FunctionFactorial>(); }
437
438
private:
439
1
    String get_name() const override { return name; }
440
33
    size_t get_number_of_arguments() const override { return 1; }
441
442
33
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
443
33
        return make_nullable(std::make_shared<DataTypeInt64>());
444
33
    }
445
446
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
447
37
                        uint32_t result, size_t input_rows_count) const override {
448
37
        const auto* data_col =
449
37
                check_and_get_column<ColumnInt64>(block.get_by_position(arguments[0]).column.get());
450
37
        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
37
        auto result_column = ColumnInt64::create(input_rows_count);
457
37
        auto result_null_map = ColumnUInt8::create(input_rows_count, 0);
458
37
        auto& result_data = result_column->get_data();
459
37
        auto& result_null_map_data = result_null_map->get_data();
460
461
37
        const auto& src_data = data_col->get_data();
462
80
        for (size_t i = 0; i < input_rows_count; ++i) {
463
43
            Int64 n = src_data[i];
464
43
            if (n < 0 || n > 20) {
465
17
                result_null_map_data[i] = 1;
466
17
                result_data[i] = 0;
467
26
            } else {
468
26
                result_data[i] = FACT_TABLE[n];
469
26
            }
470
43
        }
471
472
37
        block.replace_by_position(result, ColumnNullable::create(std::move(result_column),
473
37
                                                                 std::move(result_null_map)));
474
475
37
        return Status::OK();
476
37
    }
477
};
478
479
template <typename A>
480
struct RadiansImpl {
481
    static constexpr PrimitiveType ResultType = TYPE_DOUBLE;
482
    using DataType = typename PrimitiveTypeTraits<ResultType>::DataType;
483
37
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
484
37
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a / 180.0 *
485
37
                                                                              PiImpl::value);
486
37
    }
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
41
    static inline typename PrimitiveTypeTraits<ResultType>::CppType apply(A a) {
500
41
        return static_cast<typename PrimitiveTypeTraits<ResultType>::CppType>(a * 180.0 /
501
41
                                                                              PiImpl::value);
502
41
    }
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
561
    static std::string bin_impl(Int64 value) {
521
561
        auto n = static_cast<uint64_t>(value);
522
561
        const size_t max_bits = sizeof(uint64_t) * 8;
523
561
        char result[max_bits];
524
561
        uint32_t index = max_bits;
525
1.89k
        do {
526
1.89k
            result[--index] = '0' + (n & 1);
527
1.89k
        } while (n >>= 1);
528
561
        return std::string(result + index, max_bits - index);
529
561
    }
530
531
    static Status vector(const ColumnInt64::Container& data, ColumnString::Chars& res_data,
532
231
                         ColumnString::Offsets& res_offsets) {
533
231
        res_offsets.resize(data.size());
534
231
        size_t input_size = res_offsets.size();
535
536
792
        for (size_t i = 0; i < input_size; ++i) {
537
561
            StringOP::push_value_string(bin_impl(data[i]), i, res_data, res_offsets);
538
561
        }
539
231
        return Status::OK();
540
231
    }
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
243
    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
43
    static inline double apply(double a, double b, UInt8& is_null) {
559
43
        is_null = a <= 0 || b <= 0 || std::fabs(a - 1.0) < EPSILON;
560
43
        return std::log(b) / std::log(a);
561
43
    }
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
462
    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
305
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LogImplEE6createEv
Line
Count
Source
583
29
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7PowImplEE6createEv
Line
Count
Source
583
62
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_9Atan2ImplEE6createEv
Line
Count
Source
583
80
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE6createEv
Line
Count
Source
583
16
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE6createEv
Line
Count
Source
583
13
    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
21
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE6createEv
Line
Count
Source
583
14
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE6createEv
Line
Count
Source
583
15
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
_ZN5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE6createEv
Line
Count
Source
583
19
    static FunctionPtr create() { return std::make_shared<FunctionMathBinary<Impl>>(); }
584
585
233
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE11is_variadicEv
Line
Count
Source
585
23
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE11is_variadicEv
Line
Count
Source
585
56
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE11is_variadicEv
Line
Count
Source
585
74
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE11is_variadicEv
Line
Count
Source
585
10
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE11is_variadicEv
Line
Count
Source
585
7
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE11is_variadicEv
Line
Count
Source
585
6
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE11is_variadicEv
Line
Count
Source
585
6
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE11is_variadicEv
Line
Count
Source
585
6
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE11is_variadicEv
Line
Count
Source
585
15
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE11is_variadicEv
Line
Count
Source
585
8
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE11is_variadicEv
Line
Count
Source
585
9
    bool is_variadic() const override { return has_variadic_argument; }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE11is_variadicEv
Line
Count
Source
585
13
    bool is_variadic() const override { return has_variadic_argument; }
586
587
72
    DataTypes get_variadic_argument_types_impl() const override {
588
72
        if constexpr (has_variadic_argument) {
589
54
            return Impl::get_variadic_argument_types();
590
54
        }
591
0
        return {};
592
72
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
        if constexpr (has_variadic_argument) {
589
            return Impl::get_variadic_argument_types();
590
        }
591
6
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
        if constexpr (has_variadic_argument) {
589
            return Impl::get_variadic_argument_types();
590
        }
591
6
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
        if constexpr (has_variadic_argument) {
589
            return Impl::get_variadic_argument_types();
590
        }
591
6
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE32get_variadic_argument_types_implEv
Line
Count
Source
587
6
    DataTypes get_variadic_argument_types_impl() const override {
588
6
        if constexpr (has_variadic_argument) {
589
6
            return Impl::get_variadic_argument_types();
590
6
        }
591
0
        return {};
592
6
    }
593
594
221
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
221
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
221
        return Impl::is_nullable ? make_nullable(res) : res;
597
221
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
594
22
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
22
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
22
        return Impl::is_nullable ? make_nullable(res) : res;
597
22
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
594
55
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
55
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
55
        return Impl::is_nullable ? make_nullable(res) : res;
597
55
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
594
73
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
73
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
73
        return Impl::is_nullable ? make_nullable(res) : res;
597
73
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
9
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
9
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
9
        return Impl::is_nullable ? make_nullable(res) : res;
597
9
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
6
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
6
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
6
        return Impl::is_nullable ? make_nullable(res) : res;
597
6
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE20get_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_7GcdImplILNS_13PrimitiveTypeE6EEEE20get_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_7GcdImplILNS_13PrimitiveTypeE7EEEE20get_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_13PrimitiveTypeE4EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
14
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
14
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
14
        return Impl::is_nullable ? make_nullable(res) : res;
597
14
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
7
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
7
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
7
        return Impl::is_nullable ? make_nullable(res) : res;
597
7
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
8
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
8
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
8
        return Impl::is_nullable ? make_nullable(res) : res;
597
8
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
594
12
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
595
12
        auto res = std::make_shared<DataTypeNumber<Impl::type>>();
596
12
        return Impl::is_nullable ? make_nullable(res) : res;
597
12
    }
598
179
    bool need_replace_null_data_to_default() const override {
599
179
        return Impl::need_replace_null_data_to_default;
600
179
    }
_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
89
    bool need_replace_null_data_to_default() const override {
599
89
        return Impl::need_replace_null_data_to_default;
600
89
    }
_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
150
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE23get_number_of_argumentsEv
Line
Count
Source
602
22
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE23get_number_of_argumentsEv
Line
Count
Source
602
55
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE23get_number_of_argumentsEv
Line
Count
Source
602
73
    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
349
                        uint32_t result, size_t input_rows_count) const override {
606
349
        auto& column_left = block.get_by_position(arguments[0]).column;
607
349
        auto& column_right = block.get_by_position(arguments[1]).column;
608
349
        bool is_const_left = is_column_const(*column_left);
609
349
        bool is_const_right = is_column_const(*column_right);
610
611
349
        ColumnPtr column_result = nullptr;
612
613
349
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
349
        if (is_const_left) {
615
14
            column_result = constant_vector(column_left, column_right);
616
335
        } else if (is_const_right) {
617
30
            column_result = vector_constant(column_left, column_right);
618
305
        } else {
619
305
            column_result = vector_vector(column_left, column_right);
620
305
        }
621
349
        block.replace_by_position(result, std::move(column_result));
622
623
349
        return Status::OK();
624
349
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
21
                        uint32_t result, size_t input_rows_count) const override {
606
21
        auto& column_left = block.get_by_position(arguments[0]).column;
607
21
        auto& column_right = block.get_by_position(arguments[1]).column;
608
21
        bool is_const_left = is_column_const(*column_left);
609
21
        bool is_const_right = is_column_const(*column_right);
610
611
21
        ColumnPtr column_result = nullptr;
612
613
21
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
21
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
21
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
21
        } else {
619
21
            column_result = vector_vector(column_left, column_right);
620
21
        }
621
21
        block.replace_by_position(result, std::move(column_result));
622
623
21
        return Status::OK();
624
21
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
74
                        uint32_t result, size_t input_rows_count) const override {
606
74
        auto& column_left = block.get_by_position(arguments[0]).column;
607
74
        auto& column_right = block.get_by_position(arguments[1]).column;
608
74
        bool is_const_left = is_column_const(*column_left);
609
74
        bool is_const_right = is_column_const(*column_right);
610
611
74
        ColumnPtr column_result = nullptr;
612
613
74
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
74
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
74
        } else if (is_const_right) {
617
15
            column_result = vector_constant(column_left, column_right);
618
59
        } else {
619
59
            column_result = vector_vector(column_left, column_right);
620
59
        }
621
74
        block.replace_by_position(result, std::move(column_result));
622
623
74
        return Status::OK();
624
74
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
127
                        uint32_t result, size_t input_rows_count) const override {
606
127
        auto& column_left = block.get_by_position(arguments[0]).column;
607
127
        auto& column_right = block.get_by_position(arguments[1]).column;
608
127
        bool is_const_left = is_column_const(*column_left);
609
127
        bool is_const_right = is_column_const(*column_right);
610
611
127
        ColumnPtr column_result = nullptr;
612
613
127
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
127
        if (is_const_left) {
615
14
            column_result = constant_vector(column_left, column_right);
616
113
        } else if (is_const_right) {
617
15
            column_result = vector_constant(column_left, column_right);
618
98
        } else {
619
98
            column_result = vector_vector(column_left, column_right);
620
98
        }
621
127
        block.replace_by_position(result, std::move(column_result));
622
623
127
        return Status::OK();
624
127
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
14
                        uint32_t result, size_t input_rows_count) const override {
606
14
        auto& column_left = block.get_by_position(arguments[0]).column;
607
14
        auto& column_right = block.get_by_position(arguments[1]).column;
608
14
        bool is_const_left = is_column_const(*column_left);
609
14
        bool is_const_right = is_column_const(*column_right);
610
611
14
        ColumnPtr column_result = nullptr;
612
613
14
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
14
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
14
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
14
        } else {
619
14
            column_result = vector_vector(column_left, column_right);
620
14
        }
621
14
        block.replace_by_position(result, std::move(column_result));
622
623
14
        return Status::OK();
624
14
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
12
                        uint32_t result, size_t input_rows_count) const override {
606
12
        auto& column_left = block.get_by_position(arguments[0]).column;
607
12
        auto& column_right = block.get_by_position(arguments[1]).column;
608
12
        bool is_const_left = is_column_const(*column_left);
609
12
        bool is_const_right = is_column_const(*column_right);
610
611
12
        ColumnPtr column_result = nullptr;
612
613
12
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
12
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
12
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
12
        } else {
619
12
            column_result = vector_vector(column_left, column_right);
620
12
        }
621
12
        block.replace_by_position(result, std::move(column_result));
622
623
12
        return Status::OK();
624
12
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
11
                        uint32_t result, size_t input_rows_count) const override {
606
11
        auto& column_left = block.get_by_position(arguments[0]).column;
607
11
        auto& column_right = block.get_by_position(arguments[1]).column;
608
11
        bool is_const_left = is_column_const(*column_left);
609
11
        bool is_const_right = is_column_const(*column_right);
610
611
11
        ColumnPtr column_result = nullptr;
612
613
11
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
11
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
11
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
11
        } else {
619
11
            column_result = vector_vector(column_left, column_right);
620
11
        }
621
11
        block.replace_by_position(result, std::move(column_result));
622
623
11
        return Status::OK();
624
11
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
11
                        uint32_t result, size_t input_rows_count) const override {
606
11
        auto& column_left = block.get_by_position(arguments[0]).column;
607
11
        auto& column_right = block.get_by_position(arguments[1]).column;
608
11
        bool is_const_left = is_column_const(*column_left);
609
11
        bool is_const_right = is_column_const(*column_right);
610
611
11
        ColumnPtr column_result = nullptr;
612
613
11
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
11
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
11
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
11
        } else {
619
11
            column_result = vector_vector(column_left, column_right);
620
11
        }
621
11
        block.replace_by_position(result, std::move(column_result));
622
623
11
        return Status::OK();
624
11
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
11
                        uint32_t result, size_t input_rows_count) const override {
606
11
        auto& column_left = block.get_by_position(arguments[0]).column;
607
11
        auto& column_right = block.get_by_position(arguments[1]).column;
608
11
        bool is_const_left = is_column_const(*column_left);
609
11
        bool is_const_right = is_column_const(*column_right);
610
611
11
        ColumnPtr column_result = nullptr;
612
613
11
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
11
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
11
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
11
        } else {
619
11
            column_result = vector_vector(column_left, column_right);
620
11
        }
621
11
        block.replace_by_position(result, std::move(column_result));
622
623
11
        return Status::OK();
624
11
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
23
                        uint32_t result, size_t input_rows_count) const override {
606
23
        auto& column_left = block.get_by_position(arguments[0]).column;
607
23
        auto& column_right = block.get_by_position(arguments[1]).column;
608
23
        bool is_const_left = is_column_const(*column_left);
609
23
        bool is_const_right = is_column_const(*column_right);
610
611
23
        ColumnPtr column_result = nullptr;
612
613
23
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
23
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
23
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
23
        } else {
619
23
            column_result = vector_vector(column_left, column_right);
620
23
        }
621
23
        block.replace_by_position(result, std::move(column_result));
622
623
23
        return Status::OK();
624
23
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
13
                        uint32_t result, size_t input_rows_count) const override {
606
13
        auto& column_left = block.get_by_position(arguments[0]).column;
607
13
        auto& column_right = block.get_by_position(arguments[1]).column;
608
13
        bool is_const_left = is_column_const(*column_left);
609
13
        bool is_const_right = is_column_const(*column_right);
610
611
13
        ColumnPtr column_result = nullptr;
612
613
13
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
13
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
13
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
13
        } else {
619
13
            column_result = vector_vector(column_left, column_right);
620
13
        }
621
13
        block.replace_by_position(result, std::move(column_result));
622
623
13
        return Status::OK();
624
13
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
14
                        uint32_t result, size_t input_rows_count) const override {
606
14
        auto& column_left = block.get_by_position(arguments[0]).column;
607
14
        auto& column_right = block.get_by_position(arguments[1]).column;
608
14
        bool is_const_left = is_column_const(*column_left);
609
14
        bool is_const_right = is_column_const(*column_right);
610
611
14
        ColumnPtr column_result = nullptr;
612
613
14
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
14
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
14
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
14
        } else {
619
14
            column_result = vector_vector(column_left, column_right);
620
14
        }
621
14
        block.replace_by_position(result, std::move(column_result));
622
623
14
        return Status::OK();
624
14
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
605
18
                        uint32_t result, size_t input_rows_count) const override {
606
18
        auto& column_left = block.get_by_position(arguments[0]).column;
607
18
        auto& column_right = block.get_by_position(arguments[1]).column;
608
18
        bool is_const_left = is_column_const(*column_left);
609
18
        bool is_const_right = is_column_const(*column_right);
610
611
18
        ColumnPtr column_result = nullptr;
612
613
18
        DCHECK(!(is_const_left && is_const_right)) << "both of column can not be const";
614
18
        if (is_const_left) {
615
0
            column_result = constant_vector(column_left, column_right);
616
18
        } else if (is_const_right) {
617
0
            column_result = vector_constant(column_left, column_right);
618
18
        } else {
619
18
            column_result = vector_vector(column_left, column_right);
620
18
        }
621
18
        block.replace_by_position(result, std::move(column_result));
622
623
18
        return Status::OK();
624
18
    }
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
305
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
305
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
305
        const auto* column_right_ptr =
683
305
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
305
        auto column_result = column_type::create(column_left->size());
686
687
305
        if constexpr (Impl::is_nullable) {
688
21
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
21
            auto& a = column_left_ptr->get_data();
690
21
            auto& b = column_right_ptr->get_data();
691
21
            auto& c = column_result->get_data();
692
21
            auto& n = null_map->get_data();
693
21
            size_t size = a.size();
694
64
            for (size_t i = 0; i < size; ++i) {
695
43
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
43
            }
697
21
            return ColumnNullable::create(std::move(column_result), std::move(null_map));
698
284
        } else {
699
284
            auto& a = column_left_ptr->get_data();
700
284
            auto& b = column_right_ptr->get_data();
701
284
            auto& c = column_result->get_data();
702
284
            size_t size = a.size();
703
1.16k
            for (size_t i = 0; i < size; ++i) {
704
881
                c[i] = Impl::apply(a[i], b[i]);
705
881
            }
706
284
            return column_result;
707
284
        }
708
305
    }
_ZNK5doris18FunctionMathBinaryINS_7LogImplEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
680
21
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
21
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
21
        const auto* column_right_ptr =
683
21
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
21
        auto column_result = column_type::create(column_left->size());
686
687
21
        if constexpr (Impl::is_nullable) {
688
21
            auto null_map = ColumnUInt8::create(column_result->size(), 0);
689
21
            auto& a = column_left_ptr->get_data();
690
21
            auto& b = column_right_ptr->get_data();
691
21
            auto& c = column_result->get_data();
692
21
            auto& n = null_map->get_data();
693
21
            size_t size = a.size();
694
64
            for (size_t i = 0; i < size; ++i) {
695
43
                c[i] = Impl::apply(a[i], b[i], n[i]);
696
43
            }
697
21
            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
21
    }
_ZNK5doris18FunctionMathBinaryINS_7PowImplEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
680
59
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
59
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
59
        const auto* column_right_ptr =
683
59
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
59
        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
59
        } else {
699
59
            auto& a = column_left_ptr->get_data();
700
59
            auto& b = column_right_ptr->get_data();
701
59
            auto& c = column_result->get_data();
702
59
            size_t size = a.size();
703
189
            for (size_t i = 0; i < size; ++i) {
704
130
                c[i] = Impl::apply(a[i], b[i]);
705
130
            }
706
59
            return column_result;
707
59
        }
708
59
    }
_ZNK5doris18FunctionMathBinaryINS_9Atan2ImplEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS4_EES7_
Line
Count
Source
680
98
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
98
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
98
        const auto* column_right_ptr =
683
98
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
98
        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
98
        } else {
699
98
            auto& a = column_left_ptr->get_data();
700
98
            auto& b = column_right_ptr->get_data();
701
98
            auto& c = column_result->get_data();
702
98
            size_t size = a.size();
703
527
            for (size_t i = 0; i < size; ++i) {
704
429
                c[i] = Impl::apply(a[i], b[i]);
705
429
            }
706
98
            return column_result;
707
98
        }
708
98
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE3EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
14
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
14
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
14
        const auto* column_right_ptr =
683
14
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
14
        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
14
        } else {
699
14
            auto& a = column_left_ptr->get_data();
700
14
            auto& b = column_right_ptr->get_data();
701
14
            auto& c = column_result->get_data();
702
14
            size_t size = a.size();
703
50
            for (size_t i = 0; i < size; ++i) {
704
36
                c[i] = Impl::apply(a[i], b[i]);
705
36
            }
706
14
            return column_result;
707
14
        }
708
14
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE4EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
12
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
12
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
12
        const auto* column_right_ptr =
683
12
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
12
        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
12
        } else {
699
12
            auto& a = column_left_ptr->get_data();
700
12
            auto& b = column_right_ptr->get_data();
701
12
            auto& c = column_result->get_data();
702
12
            size_t size = a.size();
703
42
            for (size_t i = 0; i < size; ++i) {
704
30
                c[i] = Impl::apply(a[i], b[i]);
705
30
            }
706
12
            return column_result;
707
12
        }
708
12
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE5EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
11
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
11
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
11
        const auto* column_right_ptr =
683
11
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
11
        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
11
        } else {
699
11
            auto& a = column_left_ptr->get_data();
700
11
            auto& b = column_right_ptr->get_data();
701
11
            auto& c = column_result->get_data();
702
11
            size_t size = a.size();
703
46
            for (size_t i = 0; i < size; ++i) {
704
35
                c[i] = Impl::apply(a[i], b[i]);
705
35
            }
706
11
            return column_result;
707
11
        }
708
11
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE6EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
11
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
11
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
11
        const auto* column_right_ptr =
683
11
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
11
        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
11
        } else {
699
11
            auto& a = column_left_ptr->get_data();
700
11
            auto& b = column_right_ptr->get_data();
701
11
            auto& c = column_result->get_data();
702
11
            size_t size = a.size();
703
40
            for (size_t i = 0; i < size; ++i) {
704
29
                c[i] = Impl::apply(a[i], b[i]);
705
29
            }
706
11
            return column_result;
707
11
        }
708
11
    }
_ZNK5doris18FunctionMathBinaryINS_7GcdImplILNS_13PrimitiveTypeE7EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
11
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
11
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
11
        const auto* column_right_ptr =
683
11
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
11
        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
11
        } else {
699
11
            auto& a = column_left_ptr->get_data();
700
11
            auto& b = column_right_ptr->get_data();
701
11
            auto& c = column_result->get_data();
702
11
            size_t size = a.size();
703
40
            for (size_t i = 0; i < size; ++i) {
704
29
                c[i] = Impl::apply(a[i], b[i]);
705
29
            }
706
11
            return column_result;
707
11
        }
708
11
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE4EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
23
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
23
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
23
        const auto* column_right_ptr =
683
23
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
23
        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
23
        } else {
699
23
            auto& a = column_left_ptr->get_data();
700
23
            auto& b = column_right_ptr->get_data();
701
23
            auto& c = column_result->get_data();
702
23
            size_t size = a.size();
703
81
            for (size_t i = 0; i < size; ++i) {
704
58
                c[i] = Impl::apply(a[i], b[i]);
705
58
            }
706
23
            return column_result;
707
23
        }
708
23
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE5EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
13
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
13
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
13
        const auto* column_right_ptr =
683
13
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
13
        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
13
        } else {
699
13
            auto& a = column_left_ptr->get_data();
700
13
            auto& b = column_right_ptr->get_data();
701
13
            auto& c = column_result->get_data();
702
13
            size_t size = a.size();
703
50
            for (size_t i = 0; i < size; ++i) {
704
37
                c[i] = Impl::apply(a[i], b[i]);
705
37
            }
706
13
            return column_result;
707
13
        }
708
13
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE6EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
14
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
14
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
14
        const auto* column_right_ptr =
683
14
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
14
        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
14
        } else {
699
14
            auto& a = column_left_ptr->get_data();
700
14
            auto& b = column_right_ptr->get_data();
701
14
            auto& c = column_result->get_data();
702
14
            size_t size = a.size();
703
46
            for (size_t i = 0; i < size; ++i) {
704
32
                c[i] = Impl::apply(a[i], b[i]);
705
32
            }
706
14
            return column_result;
707
14
        }
708
14
    }
_ZNK5doris18FunctionMathBinaryINS_7LcmImplILNS_13PrimitiveTypeE7EEEE13vector_vectorENS_3COWINS_7IColumnEE13immutable_ptrIS6_EES9_
Line
Count
Source
680
18
    ColumnPtr vector_vector(ColumnPtr column_left, ColumnPtr column_right) const {
681
18
        const auto* column_left_ptr = assert_cast<const column_type*>(column_left->get_ptr().get());
682
18
        const auto* column_right_ptr =
683
18
                assert_cast<const column_type*>(column_right->get_ptr().get());
684
685
18
        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
18
        } else {
699
18
            auto& a = column_left_ptr->get_data();
700
18
            auto& b = column_right_ptr->get_data();
701
18
            auto& c = column_result->get_data();
702
18
            size_t size = a.size();
703
54
            for (size_t i = 0; i < size; ++i) {
704
36
                c[i] = Impl::apply(a[i], b[i]);
705
36
            }
706
18
            return column_result;
707
18
        }
708
18
    }
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
38
    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
6
    DataTypes get_variadic_argument_types_impl() const override {
724
6
        return {std::make_shared<DataTypeFloat64>(), std::make_shared<DataTypeFloat64>(),
725
6
                std::make_shared<DataTypeFloat64>()};
726
6
    }
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
39
    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
37
double EvenImpl(double a) {
798
37
    double mag = std::abs(a);
799
37
    double even_mag = 2 * std::ceil(mag / 2);
800
37
    return std::copysign(even_mag, a);
801
37
}
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
30
    static DataTypes get_variadic_argument_types() {
819
30
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
30
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
30
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE3EE27get_variadic_argument_typesEv
Line
Count
Source
818
6
    static DataTypes get_variadic_argument_types() {
819
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
6
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE4EE27get_variadic_argument_typesEv
Line
Count
Source
818
6
    static DataTypes get_variadic_argument_types() {
819
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
6
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE5EE27get_variadic_argument_typesEv
Line
Count
Source
818
6
    static DataTypes get_variadic_argument_types() {
819
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
6
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE6EE27get_variadic_argument_typesEv
Line
Count
Source
818
6
    static DataTypes get_variadic_argument_types() {
819
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
6
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE7EE27get_variadic_argument_typesEv
Line
Count
Source
818
6
    static DataTypes get_variadic_argument_types() {
819
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
820
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
821
6
    }
822
823
159
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
159
        return static_cast<cpp_type>(std::gcd(a, b));
825
159
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE3EE5applyEaa
Line
Count
Source
823
36
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
36
        return static_cast<cpp_type>(std::gcd(a, b));
825
36
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE4EE5applyEss
Line
Count
Source
823
30
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
30
        return static_cast<cpp_type>(std::gcd(a, b));
825
30
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE5EE5applyEii
Line
Count
Source
823
35
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
35
        return static_cast<cpp_type>(std::gcd(a, b));
825
35
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE6EE5applyEll
Line
Count
Source
823
29
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
29
        return static_cast<cpp_type>(std::gcd(a, b));
825
29
    }
_ZN5doris7GcdImplILNS_13PrimitiveTypeE7EE5applyEnn
Line
Count
Source
823
29
    static inline cpp_type apply(cpp_type a, cpp_type b) {
824
29
        return static_cast<cpp_type>(std::gcd(a, b));
825
29
    }
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
24
    static DataTypes get_variadic_argument_types() {
838
24
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
24
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
24
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE4EE27get_variadic_argument_typesEv
Line
Count
Source
837
6
    static DataTypes get_variadic_argument_types() {
838
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
6
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE5EE27get_variadic_argument_typesEv
Line
Count
Source
837
6
    static DataTypes get_variadic_argument_types() {
838
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
6
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE6EE27get_variadic_argument_typesEv
Line
Count
Source
837
6
    static DataTypes get_variadic_argument_types() {
838
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
6
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE7EE27get_variadic_argument_typesEv
Line
Count
Source
837
6
    static DataTypes get_variadic_argument_types() {
838
6
        using datatype = typename PrimitiveTypeTraits<A>::DataType;
839
6
        return {std::make_shared<datatype>(), std::make_shared<datatype>()};
840
6
    }
841
842
163
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
163
        return static_cast<cpp_type>(std::lcm(a, b));
844
163
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE4EE5applyEss
Line
Count
Source
842
58
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
58
        return static_cast<cpp_type>(std::lcm(a, b));
844
58
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE5EE5applyEii
Line
Count
Source
842
37
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
37
        return static_cast<cpp_type>(std::lcm(a, b));
844
37
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE6EE5applyEll
Line
Count
Source
842
32
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
32
        return static_cast<cpp_type>(std::lcm(a, b));
844
32
    }
_ZN5doris7LcmImplILNS_13PrimitiveTypeE7EE5applyEnn
Line
Count
Source
842
36
    static inline cpp_type apply(cpp_type a, cpp_type b) {
843
36
        return static_cast<cpp_type>(std::lcm(a, b));
844
36
    }
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
12
    size_t get_number_of_arguments() const override { return 1; }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE23get_number_of_argumentsEv
Line
Count
Source
872
6
    size_t get_number_of_arguments() const override { return 1; }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE23get_number_of_argumentsEv
Line
Count
Source
872
6
    size_t get_number_of_arguments() const override { return 1; }
873
874
12
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
875
12
        return std::make_shared<DataTypeBool>();
876
12
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
874
6
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
875
6
        return std::make_shared<DataTypeBool>();
876
6
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
874
6
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
875
6
        return std::make_shared<DataTypeBool>();
876
6
    }
877
878
    void execute_impl_with_type(const auto* input_column,
879
12
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
48
        for (int i = 0; i < size; i++) {
881
36
            auto value = input_column->get_element(i);
882
36
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
18
                output[i] = std::isnan(value);
884
18
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
18
                output[i] = std::isinf(value);
886
18
            }
887
36
        }
888
12
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE22execute_impl_with_typeINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEEEvPKT_RNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEm
Line
Count
Source
879
5
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
16
        for (int i = 0; i < size; i++) {
881
11
            auto value = input_column->get_element(i);
882
11
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
11
                output[i] = std::isnan(value);
884
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
                output[i] = std::isinf(value);
886
            }
887
11
        }
888
5
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE22execute_impl_with_typeINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEEvPKT_RNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEm
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_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEm
Line
Count
Source
879
5
                                DataTypeBool::ColumnType::Container& output, size_t size) const {
880
16
        for (int i = 0; i < size; i++) {
881
11
            auto value = input_column->get_element(i);
882
            if constexpr (Impl::type == FloatPointNumberJudgmentType::IsNan) {
883
                output[i] = std::isnan(value);
884
11
            } else if constexpr (Impl::type == FloatPointNumberJudgmentType::IsInf) {
885
11
                output[i] = std::isinf(value);
886
11
            }
887
11
        }
888
5
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE22execute_impl_with_typeINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEEvPKT_RNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEm
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
12
                        uint32_t result, size_t input_rows_count) const override {
892
12
        auto dst = DataTypeBool::ColumnType::create();
893
12
        auto& dst_data = dst->get_data();
894
12
        dst_data.resize(input_rows_count);
895
12
        const auto* column = block.get_by_position(arguments[0]).column.get();
896
12
        if (const auto* col_f64 = check_and_get_column<ColumnFloat64>(column)) {
897
10
            execute_impl_with_type(col_f64, dst_data, input_rows_count);
898
10
        } 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
12
        block.replace_by_position(result, std::move(dst));
905
12
        return Status::OK();
906
12
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsNanEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
891
6
                        uint32_t result, size_t input_rows_count) const override {
892
6
        auto dst = DataTypeBool::ColumnType::create();
893
6
        auto& dst_data = dst->get_data();
894
6
        dst_data.resize(input_rows_count);
895
6
        const auto* column = block.get_by_position(arguments[0]).column.get();
896
6
        if (const auto* col_f64 = check_and_get_column<ColumnFloat64>(column)) {
897
5
            execute_impl_with_type(col_f64, dst_data, input_rows_count);
898
5
        } 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
6
        block.replace_by_position(result, std::move(dst));
905
6
        return Status::OK();
906
6
    }
_ZNK5doris35FunctionFloatingPointNumberJudgmentINS_9ImplIsInfEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
891
6
                        uint32_t result, size_t input_rows_count) const override {
892
6
        auto dst = DataTypeBool::ColumnType::create();
893
6
        auto& dst_data = dst->get_data();
894
6
        dst_data.resize(input_rows_count);
895
6
        const auto* column = block.get_by_position(arguments[0]).column.get();
896
6
        if (const auto* col_f64 = check_and_get_column<ColumnFloat64>(column)) {
897
5
            execute_impl_with_type(col_f64, dst_data, input_rows_count);
898
5
        } 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
6
        block.replace_by_position(result, std::move(dst));
905
6
        return Status::OK();
906
6
    }
907
};
908
909
using FunctionIsNan = FunctionFloatingPointNumberJudgment<ImplIsNan>;
910
using FunctionIsInf = FunctionFloatingPointNumberJudgment<ImplIsInf>;
911
912
6
void register_function_math(SimpleFunctionFactory& factory) {
913
6
    factory.register_function<FunctionAcos>();
914
6
    factory.register_function<FunctionAcosh>();
915
6
    factory.register_function<FunctionAsin>();
916
6
    factory.register_function<FunctionAsinh>();
917
6
    factory.register_function<FunctionAtan>();
918
6
    factory.register_function<FunctionAtanh>();
919
6
    factory.register_function<FunctionMathBinary<LogImpl>>();
920
6
    factory.register_function<FunctionMathBinary<PowImpl>>();
921
6
    factory.register_function<FunctionMathBinary<Atan2Impl>>();
922
6
    factory.register_function<FunctionCos>();
923
6
    factory.register_function<FunctionCosh>();
924
6
    factory.register_function<FunctionE>();
925
6
    factory.register_alias("ln", "dlog1");
926
6
    factory.register_function<FunctionMathLog<ImplLn>>();
927
6
    factory.register_function<FunctionMathLog<ImplLog2>>();
928
6
    factory.register_function<FunctionMathLog<ImplLog10>>();
929
6
    factory.register_alias("log10", "dlog10");
930
6
    factory.register_function<FunctionPi>();
931
6
    factory.register_function<FunctionSign>();
932
6
    factory.register_function<FunctionAbsInt8>();
933
6
    factory.register_function<FunctionAbsInt16>();
934
6
    factory.register_function<FunctionAbsInt32>();
935
6
    factory.register_function<FunctionAbsInt64>();
936
6
    factory.register_function<FunctionAbsInt128>();
937
6
    factory.register_function<FunctionAbsUInt8>();
938
6
    factory.register_function<FunctionAbsDecimal32>();
939
6
    factory.register_function<FunctionAbsDecimal64>();
940
6
    factory.register_function<FunctionAbsDecimalV3>();
941
6
    factory.register_function<FunctionAbsDecimalV2>();
942
6
    factory.register_function<FunctionAbsDecimal256>();
943
6
    factory.register_function<FunctionAbsFloat>();
944
6
    factory.register_function<FunctionAbsDouble>();
945
6
    factory.register_function<FunctionNegativeDouble>();
946
6
    factory.register_function<FunctionNegativeBigInt>();
947
6
    factory.register_function<FunctionNegativeDecimalV2>();
948
6
    factory.register_function<FunctionNegativeDecimal256>();
949
6
    factory.register_function<FunctionNegativeDecimalV3>();
950
6
    factory.register_function<FunctionNegativeDecimal32>();
951
6
    factory.register_function<FunctionNegativeDecimal64>();
952
953
6
    factory.register_function<FunctionPositiveDecimal32>();
954
6
    factory.register_function<FunctionPositiveDecimal64>();
955
6
    factory.register_function<FunctionPositiveDecimalV3>();
956
6
    factory.register_function<FunctionPositiveDecimalV2>();
957
6
    factory.register_function<FunctionPositiveDecimal256>();
958
6
    factory.register_function<FunctionPositiveDouble>();
959
6
    factory.register_function<FunctionPositiveBigInt>();
960
961
6
    factory.register_function<FunctionSin>();
962
6
    factory.register_function<FunctionSinh>();
963
6
    factory.register_function<FunctionSqrt>();
964
6
    factory.register_alias("sqrt", "dsqrt");
965
6
    factory.register_function<FunctionCbrt>();
966
6
    factory.register_function<FunctionTan>();
967
6
    factory.register_function<FunctionTanh>();
968
6
    factory.register_function<FunctionCot>();
969
6
    factory.register_function<FunctionSec>();
970
6
    factory.register_function<FunctionCosec>();
971
6
    factory.register_alias("pow", "power");
972
6
    factory.register_alias("pow", "dpow");
973
6
    factory.register_alias("pow", "fpow");
974
6
    factory.register_function<FunctionExp>();
975
6
    factory.register_alias("exp", "dexp");
976
6
    factory.register_function<FunctionFactorial>();
977
6
    factory.register_function<FunctionRadians>();
978
6
    factory.register_function<FunctionDegrees>();
979
6
    factory.register_function<FunctionBin>();
980
6
    factory.register_function<FunctionNormalCdf>();
981
6
    factory.register_function<FunctionSignBit>();
982
6
    factory.register_function<FunctionEven>();
983
6
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_TINYINT>>>();
984
6
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_SMALLINT>>>();
985
6
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_INT>>>();
986
6
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_BIGINT>>>();
987
6
    factory.register_function<FunctionMathBinary<GcdImpl<TYPE_LARGEINT>>>();
988
6
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_SMALLINT>>>();
989
6
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_INT>>>();
990
6
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_BIGINT>>>();
991
6
    factory.register_function<FunctionMathBinary<LcmImpl<TYPE_LARGEINT>>>();
992
6
    factory.register_function<FunctionIsNan>();
993
6
    factory.register_function<FunctionIsInf>();
994
6
}
995
} // namespace doris