Coverage Report

Created: 2026-09-30 16:12

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