1#include <Functions/FunctionFactory.h>
2#include <Functions/FunctionUnaryArithmetic.h>
3
4namespace DB
5{
6
7template <typename A>
8struct RoundAgeImpl
9{
10 using ResultType = UInt8;
11
12 static inline ResultType apply(A x)
13 {
14 return x < 1 ? 0
15 : (x < 18 ? 17
16 : (x < 25 ? 18
17 : (x < 35 ? 25
18 : (x < 45 ? 35
19 : (x < 55 ? 45
20 : 55)))));
21 }
22
23#if USE_EMBEDDED_COMPILER
24 static constexpr bool compilable = false;
25#endif
26};
27
28struct NameRoundAge { static constexpr auto name = "roundAge"; };
29using FunctionRoundAge = FunctionUnaryArithmetic<RoundAgeImpl, NameRoundAge, false>;
30
31template <> struct FunctionUnaryArithmeticMonotonicity<NameRoundAge> : PositiveMonotonicity {};
32
33void registerFunctionRoundAge(FunctionFactory & factory)
34{
35 factory.registerFunction<FunctionRoundAge>();
36}
37
38}
39