1#include <Functions/FunctionFactory.h>
2#include <Functions/FunctionUnaryArithmetic.h>
3#include <Common/FieldVisitors.h>
4#include <Common/intExp.h>
5
6namespace DB
7{
8
9template <typename A>
10struct IntExp10Impl
11{
12 using ResultType = UInt64;
13
14 static inline ResultType apply(A a)
15 {
16 return intExp10(a);
17 }
18
19#if USE_EMBEDDED_COMPILER
20 static constexpr bool compilable = false; /// library function
21#endif
22};
23
24struct NameIntExp10 { static constexpr auto name = "intExp10"; };
25/// Assumed to be injective for the purpose of query optimization, but in fact it is not injective because of possible overflow.
26using FunctionIntExp10 = FunctionUnaryArithmetic<IntExp10Impl, NameIntExp10, true>;
27
28template <> struct FunctionUnaryArithmeticMonotonicity<NameIntExp10>
29{
30 static bool has() { return true; }
31 static IFunction::Monotonicity get(const Field & left, const Field & right)
32 {
33 Float64 left_float = left.isNull() ? -std::numeric_limits<Float64>::infinity() : applyVisitor(FieldVisitorConvertToNumber<Float64>(), left);
34 Float64 right_float = right.isNull() ? std::numeric_limits<Float64>::infinity() : applyVisitor(FieldVisitorConvertToNumber<Float64>(), right);
35
36 if (left_float < 0 || right_float > 19)
37 return {};
38
39 return { true };
40 }
41};
42
43void registerFunctionIntExp10(FunctionFactory & factory)
44{
45 factory.registerFunction<FunctionIntExp10>();
46}
47
48}
49