1 | #include <Functions/FunctionFactory.h> |
---|---|
2 | #include <Functions/FunctionUnaryArithmetic.h> |
3 | #include <Common/FieldVisitors.h> |
4 | #include <Common/intExp.h> |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | template <typename A> |
10 | struct 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 | |
24 | struct 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. |
26 | using FunctionIntExp10 = FunctionUnaryArithmetic<IntExp10Impl, NameIntExp10, true>; |
27 | |
28 | template <> 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 | |
43 | void registerFunctionIntExp10(FunctionFactory & factory) |
44 | { |
45 | factory.registerFunction<FunctionIntExp10>(); |
46 | } |
47 | |
48 | } |
49 |