diff --git a/be/src/vec/functions/math.cpp b/be/src/vec/functions/math.cpp index bc086ce444730f..a3b54c8026db75 100644 --- a/be/src/vec/functions/math.cpp +++ b/be/src/vec/functions/math.cpp @@ -19,6 +19,8 @@ #include // IWYU pragma: no_include +#include + #include #include #include @@ -214,10 +216,29 @@ struct NamePositive { using FunctionPositive = FunctionUnaryArithmetic; -struct SinName { +struct UnaryFunctionPlainSin { + using Type = DataTypeFloat64; static constexpr auto name = "sin"; + using FuncType = double (*)(double); + + static FuncType get_sin_func() { + void* handle = dlopen("libm.so.6", RTLD_LAZY); + if (handle) { + if (auto sin_func = (double (*)(double))dlsym(handle, "sin"); sin_func) { + return sin_func; + } + dlclose(handle); + } + return std::sin; + } + + static void execute(const double* src, double* dst) { + static auto sin_func = get_sin_func(); + *dst = sin_func(*src); + } }; -using FunctionSin = FunctionMathUnary>; + +using FunctionSin = FunctionMathUnary; struct SqrtName { static constexpr auto name = "sqrt";