mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #67558 from yariks5s/fix_datetime64_toStartOfWeek
Fix toStartOfWeek wrong result with DateTime64
This commit is contained in:
commit
593af842f5
@ -24,7 +24,7 @@ namespace DB
|
|||||||
|
|
||||||
static constexpr auto millisecond_multiplier = 1'000;
|
static constexpr auto millisecond_multiplier = 1'000;
|
||||||
static constexpr auto microsecond_multiplier = 1'000'000;
|
static constexpr auto microsecond_multiplier = 1'000'000;
|
||||||
static constexpr auto nanosecond_multiplier = 1'000'000'000;
|
static constexpr auto nanosecond_multiplier = 1'000'000'000;
|
||||||
|
|
||||||
static constexpr FormatSettings::DateTimeOverflowBehavior default_date_time_overflow_behavior = FormatSettings::DateTimeOverflowBehavior::Ignore;
|
static constexpr FormatSettings::DateTimeOverflowBehavior default_date_time_overflow_behavior = FormatSettings::DateTimeOverflowBehavior::Ignore;
|
||||||
|
|
||||||
@ -381,11 +381,13 @@ struct ToStartOfWeekImpl
|
|||||||
|
|
||||||
static UInt16 execute(Int64 t, UInt8 week_mode, const DateLUTImpl & time_zone)
|
static UInt16 execute(Int64 t, UInt8 week_mode, const DateLUTImpl & time_zone)
|
||||||
{
|
{
|
||||||
return time_zone.toFirstDayNumOfWeek(time_zone.toDayNum(t), week_mode);
|
const int res = time_zone.toFirstDayNumOfWeek(time_zone.toDayNum(t), week_mode);
|
||||||
|
return std::max(res, 0);
|
||||||
}
|
}
|
||||||
static UInt16 execute(UInt32 t, UInt8 week_mode, const DateLUTImpl & time_zone)
|
static UInt16 execute(UInt32 t, UInt8 week_mode, const DateLUTImpl & time_zone)
|
||||||
{
|
{
|
||||||
return time_zone.toFirstDayNumOfWeek(time_zone.toDayNum(t), week_mode);
|
const int res = time_zone.toFirstDayNumOfWeek(time_zone.toDayNum(t), week_mode);
|
||||||
|
return std::max(res, 0);
|
||||||
}
|
}
|
||||||
static UInt16 execute(Int32 d, UInt8 week_mode, const DateLUTImpl & time_zone)
|
static UInt16 execute(Int32 d, UInt8 week_mode, const DateLUTImpl & time_zone)
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ toStartOfMonth;toDateTime64;false 2099-07-07
|
|||||||
type;toStartOfMonth;toDateTime64;false Date
|
type;toStartOfMonth;toDateTime64;false Date
|
||||||
toStartOfWeek;toDate32;false 2099-07-07
|
toStartOfWeek;toDate32;false 2099-07-07
|
||||||
type;toStartOfWeek;toDate32;false Date
|
type;toStartOfWeek;toDate32;false Date
|
||||||
toStartOfWeek;toDateTime64;false 2099-07-07
|
toStartOfWeek;toDateTime64;false 1970-01-01
|
||||||
type;toStartOfWeek;toDateTime64;false Date
|
type;toStartOfWeek;toDateTime64;false Date
|
||||||
toMonday;toDate32;false 2099-07-08
|
toMonday;toDate32;false 2099-07-08
|
||||||
type;toMonday;toDate32;false Date
|
type;toMonday;toDate32;false Date
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
1970-01-01
|
||||||
|
1970-01-01
|
@ -0,0 +1,2 @@
|
|||||||
|
SELECT toStartOfWeek(toDateTime64('1970-01-01', 6));
|
||||||
|
SELECT toStartOfWeek(toDateTime('1970-01-01'));
|
Loading…
Reference in New Issue
Block a user