mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 17:20:50 +00:00
dbms: Server: Added function toStartOfFiveMinute. [#METR-14495]
This commit is contained in:
parent
de8ad31161
commit
ce1e437c09
@ -17,8 +17,8 @@ namespace DB
|
||||
/** Функции работы с датой и временем.
|
||||
*
|
||||
* toYear, toMonth, toDayOfMonth, toDayOfWeek, toHour, toMinute, toSecond,
|
||||
* toMonday, toStartOfMonth, toStartOfYear, toStartOfMinute, toStartOfHour
|
||||
* toTime,
|
||||
* toMonday, toStartOfMonth, toStartOfYear, toStartOfMinute, toStartOfFiveMinute
|
||||
* toStartOfHour, toTime,
|
||||
* now
|
||||
* TODO: makeDate, makeDateTime
|
||||
*
|
||||
@ -141,6 +141,15 @@ struct ToStartOfMinuteImpl
|
||||
}
|
||||
};
|
||||
|
||||
struct ToStartOfFiveMinuteImpl
|
||||
{
|
||||
static inline UInt32 execute(UInt32 t, DateLUT & date_lut) { return date_lut.toStartOfFiveMinuteInaccurate(t); }
|
||||
static inline UInt32 execute(UInt16 d, DateLUT & date_lut)
|
||||
{
|
||||
throw Exception("Illegal type Date of argument for function toStartOfFiveMinute", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
}
|
||||
};
|
||||
|
||||
struct ToStartOfHourImpl
|
||||
{
|
||||
static inline UInt32 execute(UInt32 t, DateLUT & date_lut) { return date_lut.toStartOfHourInaccurate(t); }
|
||||
@ -597,6 +606,7 @@ struct NameToStartOfMonth { static constexpr auto name = "toStartOfMonth"; };
|
||||
struct NameToStartOfQuarter { static constexpr auto name = "toStartOfQuarter"; };
|
||||
struct NameToStartOfYear { static constexpr auto name = "toStartOfYear"; };
|
||||
struct NameToStartOfMinute { static constexpr auto name = "toStartOfMinute"; };
|
||||
struct NameToStartOfFiveMinute { static constexpr auto name = "toStartOfFiveMinute"; };
|
||||
struct NameToStartOfHour { static constexpr auto name = "toStartOfHour"; };
|
||||
struct NameToTime { static constexpr auto name = "toTime"; };
|
||||
struct NameToRelativeYearNum { static constexpr auto name = "toRelativeYearNum"; };
|
||||
@ -620,6 +630,7 @@ typedef FunctionDateOrDateTimeToSomething<DataTypeDate, ToStartOfMonthImpl, Nam
|
||||
typedef FunctionDateOrDateTimeToSomething<DataTypeDate, ToStartOfQuarterImpl, NameToStartOfQuarter> FunctionToStartOfQuarter;
|
||||
typedef FunctionDateOrDateTimeToSomething<DataTypeDate, ToStartOfYearImpl, NameToStartOfYear> FunctionToStartOfYear;
|
||||
typedef FunctionDateOrDateTimeToSomething<DataTypeDateTime, ToStartOfMinuteImpl, NameToStartOfMinute> FunctionToStartOfMinute;
|
||||
typedef FunctionDateOrDateTimeToSomething<DataTypeDateTime, ToStartOfFiveMinuteImpl, NameToStartOfFiveMinute> FunctionToStartOfFiveMinute;
|
||||
typedef FunctionDateOrDateTimeToSomething<DataTypeDateTime, ToStartOfHourImpl, NameToStartOfHour> FunctionToStartOfHour;
|
||||
typedef FunctionDateOrDateTimeToSomething<DataTypeDateTime, ToTimeImpl, NameToTime> FunctionToTime;
|
||||
|
||||
|
@ -18,6 +18,7 @@ void registerFunctionsDateTime(FunctionFactory & factory)
|
||||
factory.registerFunction<FunctionToStartOfQuarter>();
|
||||
factory.registerFunction<FunctionToStartOfYear>();
|
||||
factory.registerFunction<FunctionToStartOfMinute>();
|
||||
factory.registerFunction<FunctionToStartOfFiveMinute>();
|
||||
factory.registerFunction<FunctionToStartOfHour>();
|
||||
factory.registerFunction<FunctionToRelativeYearNum>();
|
||||
factory.registerFunction<FunctionToRelativeMonthNum>();
|
||||
|
Loading…
Reference in New Issue
Block a user