ClickHouse/src/Functions/intDivOrZero.cpp
Li Yin 4088c0a7f3 Automated function registration
Automated register all functions with below naming convention by
iterating through the symbols:
void DB::registerXXX(DB::FunctionFactory &)
2022-07-29 15:39:50 +08:00

38 lines
1007 B
C++

#include <Functions/FunctionFactory.h>
#include <Functions/FunctionBinaryArithmetic.h>
namespace DB
{
template <typename A, typename B>
struct DivideIntegralOrZeroImpl
{
using ResultType = typename NumberTraits::ResultOfIntegerDivision<A, B>::Type;
static const constexpr bool allow_fixed_string = false;
static const constexpr bool allow_string_integer = false;
template <typename Result = ResultType>
static inline Result apply(A a, B b)
{
if (unlikely(divisionLeadsToFPE(a, b)))
return 0;
return DivideIntegralImpl<A, B>::template apply<Result>(a, b);
}
#if USE_EMBEDDED_COMPILER
static constexpr bool compilable = false; /// TODO implement the checks
#endif
};
struct NameIntDivOrZero { static constexpr auto name = "intDivOrZero"; };
using FunctionIntDivOrZero = BinaryArithmeticOverloadResolver<DivideIntegralOrZeroImpl, NameIntDivOrZero>;
REGISTER_FUNCTION(IntDivOrZero)
{
factory.registerFunction<FunctionIntDivOrZero>();
}
}