#include #include namespace DB { template struct ModuloOrZeroImpl { using ResultType = typename NumberTraits::ResultOfModulo::Type; static const constexpr bool allow_fixed_string = false; template static inline Result apply(A a, B b) { if constexpr (std::is_floating_point_v) { return ResultType(a) - trunc(ResultType(a) / ResultType(b)) * ResultType(b); } else { if (unlikely(divisionLeadsToFPE(a, b))) return 0; return ModuloImpl::template apply(a, b); } } #if USE_EMBEDDED_COMPILER static constexpr bool compilable = false; /// TODO implement the checks #endif }; struct NameModuloOrZero { static constexpr auto name = "moduloOrZero"; }; using FunctionModuloOrZero = FunctionBinaryArithmetic; void registerFunctionModuloOrZero(FunctionFactory & factory) { factory.registerFunction(); } }