ClickHouse/dbms/src/Functions/roundAge.cpp
alexey-milovidov e00ce0bb57
Every function in its own file, part 7 (#3666)
* Every function in its own file, part 7 [#CLICKHOUSE-2]

* Every function in its own file, part 7 [#CLICKHOUSE-2]

* Every function in its own file, part 7 [#CLICKHOUSE-2]

* Every function in its own file, part 7 [#CLICKHOUSE-2]

* Every function in its own file, part 7 [#CLICKHOUSE-2]

* Fixed build #3666
2018-11-26 19:20:40 +03:00

39 lines
860 B
C++

#include <Functions/FunctionFactory.h>
#include <Functions/FunctionUnaryArithmetic.h>
namespace DB
{
template <typename A>
struct RoundAgeImpl
{
using ResultType = UInt8;
static inline ResultType apply(A x)
{
return x < 1 ? 0
: (x < 18 ? 17
: (x < 25 ? 18
: (x < 35 ? 25
: (x < 45 ? 35
: (x < 55 ? 45
: 55)))));
}
#if USE_EMBEDDED_COMPILER
static constexpr bool compilable = false;
#endif
};
struct NameRoundAge { static constexpr auto name = "roundAge"; };
using FunctionRoundAge = FunctionUnaryArithmetic<RoundAgeImpl, NameRoundAge, false>;
template <> struct FunctionUnaryArithmeticMonotonicity<NameRoundAge> : PositiveMonotonicity {};
void registerFunctionRoundAge(FunctionFactory & factory)
{
factory.registerFunction<FunctionRoundAge>();
}
}