#include #include #include namespace DB { template struct NegateImpl { using ResultType = std::conditional_t, A, typename NumberTraits::ResultOfNegate::Type>; static constexpr const bool allow_string_or_fixed_string = false; static inline NO_SANITIZE_UNDEFINED ResultType apply(A a) { return -static_cast(a); } #if USE_EMBEDDED_COMPILER static constexpr bool compilable = true; static inline llvm::Value * compile(llvm::IRBuilder<> & b, llvm::Value * arg, bool) { return arg->getType()->isIntegerTy() ? b.CreateNeg(arg) : b.CreateFNeg(arg); } #endif }; struct NameNegate { static constexpr auto name = "negate"; }; using FunctionNegate = FunctionUnaryArithmetic; template <> struct FunctionUnaryArithmeticMonotonicity { static bool has() { return true; } static IFunction::Monotonicity get(const Field &, const Field &) { return { .is_monotonic = true, .is_positive = false, .is_strict = true }; } }; REGISTER_FUNCTION(Negate) { factory.registerFunction(); } }