mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 01:00:48 +00:00
fix test fails
This commit is contained in:
parent
5c00428940
commit
a61fd73c88
@ -65,12 +65,7 @@ struct ToStartOfWeekImpl
|
||||
if (t < 0)
|
||||
return 0;
|
||||
|
||||
auto res = time_zone.toFirstDayNumOfWeek(DayNum(std::min(time_t(time_zone.toDayNum(t)), time_t(DATE_LUT_MAX_DAY_NUM))), week_mode);
|
||||
|
||||
if (res > time_zone.toDayNum(t))
|
||||
return 0;
|
||||
else
|
||||
return res;
|
||||
return time_zone.toFirstDayNumOfWeek(DayNum(std::min(time_t(time_zone.toDayNum(t)), time_t(DATE_LUT_MAX_DAY_NUM))), week_mode);
|
||||
}
|
||||
static inline UInt16 execute(UInt32 t, UInt8 week_mode, const DateLUTImpl & time_zone)
|
||||
{
|
||||
@ -81,21 +76,11 @@ struct ToStartOfWeekImpl
|
||||
if (d < 0)
|
||||
return 0;
|
||||
|
||||
auto res = time_zone.toFirstDayNumOfWeek(DayNum(std::min(d, DATE_LUT_MAX_DAY_NUM)), week_mode);
|
||||
|
||||
if (res > d)
|
||||
return 0;
|
||||
else
|
||||
return res;
|
||||
return time_zone.toFirstDayNumOfWeek(DayNum(std::min(d, DATE_LUT_MAX_DAY_NUM)), week_mode);
|
||||
}
|
||||
static inline UInt16 execute(UInt16 d, UInt8 week_mode, const DateLUTImpl & time_zone)
|
||||
{
|
||||
auto res = time_zone.toFirstDayNumOfWeek(d, week_mode);
|
||||
|
||||
if (res > d)
|
||||
return 0;
|
||||
else
|
||||
return res;
|
||||
return time_zone.toFirstDayNumOfWeek(DayNum(d), week_mode);
|
||||
}
|
||||
|
||||
using FactorTransform = ZeroTransform;
|
||||
|
@ -379,8 +379,9 @@ struct ToDateTransform32Or64
|
||||
if (from < 0)
|
||||
return 0;
|
||||
|
||||
auto day_num = time_zone.toDayNum(from);
|
||||
return day_num < DATE_LUT_MAX_DAY_NUM ? day_num : DATE_LUT_MAX_DAY_NUM;
|
||||
return (from < DATE_LUT_MAX_DAY_NUM)
|
||||
? from
|
||||
: std::min(UInt64(time_zone.toDayNum(from)), UInt64(DATE_LUT_MAX_DAY_NUM));
|
||||
}
|
||||
};
|
||||
|
||||
@ -398,6 +399,11 @@ struct ToDateTransform32Or64Signed
|
||||
|
||||
auto day_num = time_zone.toDayNum(ExtendedDayNum(from));
|
||||
return day_num < DATE_LUT_MAX_DAY_NUM ? day_num : DATE_LUT_MAX_DAY_NUM;
|
||||
|
||||
return (from < DATE_LUT_MAX_DAY_NUM)
|
||||
? from
|
||||
: std::min(UInt64(time_zone.toDayNum(from)), UInt64(0xFFFFFFFF));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -426,7 +432,9 @@ struct ToDate32Transform32Or64
|
||||
|
||||
static inline NO_SANITIZE_UNDEFINED ToType execute(const FromType & from, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return std::min(time_t(time_zone.toDayNum(from)), time_t(DATE_LUT_MAX_EXTEND_DAY_NUM));
|
||||
return (from < DATE_LUT_MAX_EXTEND_DAY_NUM)
|
||||
? from
|
||||
: std::min(UInt64(time_zone.toDayNum(from)), UInt64(DATE_LUT_MAX_EXTEND_DAY_NUM));
|
||||
}
|
||||
};
|
||||
|
||||
@ -442,7 +450,7 @@ struct ToDate32Transform32Or64Signed
|
||||
return daynum_min_offset;
|
||||
return (from < DATE_LUT_MAX_EXTEND_DAY_NUM)
|
||||
? from
|
||||
: time_zone.toDayNum(std::min(time_t(from), time_t(0xFFFFFFFF)));
|
||||
: time_zone.toDayNum(std::min(Int64(from), Int64(0xFFFFFFFF)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -544,14 +552,12 @@ struct ToDateTimeTransform64Signed
|
||||
{
|
||||
static constexpr auto name = "toDateTime";
|
||||
|
||||
static inline NO_SANITIZE_UNDEFINED ToType execute(const FromType & from, const DateLUTImpl & time_zone)
|
||||
static inline NO_SANITIZE_UNDEFINED ToType execute(const FromType & from, const DateLUTImpl & /* time_zone */)
|
||||
{
|
||||
if (from < 0)
|
||||
return 0;
|
||||
else if (time_zone.toDayNum(from) > DATE_LUT_MAX_DAY_NUM)
|
||||
return DATE_LUT_MAX_DAY_NUM;
|
||||
else
|
||||
return time_t(from);
|
||||
|
||||
return std::min(Int64(from), Int64(0xFFFFFFFF));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -49,4 +49,3 @@ SELECT
|
||||
toStartOfWeek(x, 3) AS w3,
|
||||
toStartOfWeek(x_t, 3) AS wt3
|
||||
FROM numbers(10);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
0
|
||||
1970-01-01 2106-02-07 1970-04-11 1970-01-01 2149-06-06
|
||||
1970-01-01 2120-07-26 1970-04-11 1970-01-01 2149-06-06
|
||||
1970-01-01 02:00:00 2106-02-07 09:28:15 1970-01-01 02:16:40
|
||||
2000-01-01 13:12:12
|
||||
|
@ -43,16 +43,16 @@
|
||||
-------toMinute---------
|
||||
-------toSecond---------
|
||||
-------toStartOfDay---------
|
||||
2036-02-07 07:31:20
|
||||
2036-02-07 07:31:20
|
||||
2027-10-01 11:03:28
|
||||
2027-10-17 11:03:28
|
||||
1970-01-01 02:00:00
|
||||
1970-01-01 02:00:00
|
||||
2106-02-07 00:00:00
|
||||
2106-02-07 00:00:00
|
||||
2021-06-22 00:00:00
|
||||
-------toMonday---------
|
||||
2079-06-07
|
||||
2079-06-07
|
||||
2120-07-06
|
||||
2120-07-20
|
||||
1970-01-01
|
||||
1970-01-01
|
||||
2149-06-02
|
||||
2149-06-02
|
||||
2021-06-21
|
||||
-------toISOWeek---------
|
||||
1
|
||||
@ -79,28 +79,28 @@
|
||||
229953
|
||||
202125
|
||||
-------toStartOfWeek---------
|
||||
2079-06-06
|
||||
2079-06-06
|
||||
2120-07-05
|
||||
2120-07-26
|
||||
1970-01-01
|
||||
1970-01-01
|
||||
2149-06-01
|
||||
2149-06-01
|
||||
2021-06-20
|
||||
-------toStartOfMonth---------
|
||||
2079-06-07
|
||||
2079-06-07
|
||||
2120-06-26
|
||||
2120-06-26
|
||||
1970-01-01
|
||||
1970-01-01
|
||||
2149-06-01
|
||||
2149-06-01
|
||||
2021-06-01
|
||||
-------toStartOfQuarter---------
|
||||
2079-06-07
|
||||
2079-06-07
|
||||
2120-04-26
|
||||
2120-04-26
|
||||
1970-01-01
|
||||
1970-01-01
|
||||
2149-04-01
|
||||
2149-04-01
|
||||
2021-04-01
|
||||
-------toStartOfYear---------
|
||||
2079-06-07
|
||||
2079-06-07
|
||||
2119-07-28
|
||||
2119-07-28
|
||||
1970-01-01
|
||||
1970-01-01
|
||||
2149-01-01
|
||||
2149-01-01
|
||||
2021-01-01
|
||||
-------toStartOfSecond---------
|
||||
-------toStartOfMinute---------
|
||||
|
@ -1,4 +1,4 @@
|
||||
1970-01-01 2149-06-06 1970-01-01 2149-06-06 1900-01-01 1970-01-02 1970-01-01 03:00:00 1970-01-01 21:12:15
|
||||
1970-01-01 2149-06-06 1970-01-01 2149-06-06 1900-01-01 1970-01-02 1970-01-01 00:00:00 2106-02-07 06:28:15
|
||||
1970-01-01 2149-06-06
|
||||
1970-01-01 2149-06-06
|
||||
1970-01-01 00:00:00 2106-02-07 06:28:15
|
||||
|
@ -1,12 +1,12 @@
|
||||
-- check conversion of numbers to date/time --
|
||||
SELECT toDate(toInt32(toDate32('1930-01-01'))),
|
||||
toDate(toInt32(toDate32('2151-01-01'))),
|
||||
toDate(toInt64(toDateTime64('1930-01-01 12:12:12.123', 3))),
|
||||
toDate(toInt64(toDateTime64('2151-01-01 12:12:12.123', 3))),
|
||||
toDate(toInt64(toDateTime64('1930-01-01 12:12:12.123', 3, 'UTC'))),
|
||||
toDate(toInt64(toDateTime64('2151-01-01 12:12:12.123', 3, 'UTC'))),
|
||||
toDate32(toInt32(toDate32('1900-01-01')) - 1),
|
||||
toDate32(toInt32(toDate32('2299-12-31')) + 1),
|
||||
toDateTime(toInt64(toDateTime64('1930-01-01 12:12:12.123', 3))),
|
||||
toDateTime(toInt64(toDateTime64('2151-01-01 12:12:12.123', 3)));
|
||||
toDateTime(toInt64(toDateTime64('1930-01-01 12:12:12.123', 3, 'UTC')), 'UTC'),
|
||||
toDateTime(toInt64(toDateTime64('2151-01-01 12:12:12.123', 3, 'UTC')), 'UTC');
|
||||
|
||||
-- check conversion of extended range type to normal range type --
|
||||
SELECT toDate(toDate32('1930-01-01')),
|
||||
@ -34,8 +34,8 @@ SELECT toStartOfDay(toDate('2141-01-01', 'UTC'), 'UTC'),
|
||||
SELECT 'toStartOfWeek';
|
||||
SELECT toStartOfWeek(toDate('1970-01-01')),
|
||||
toStartOfWeek(toDate32('1970-01-01')),
|
||||
toStartOfWeek(toDateTime('1970-01-01 10:10:10')),
|
||||
toStartOfWeek(toDateTime64('1970-01-01 10:10:10.123', 3)),
|
||||
toStartOfWeek(toDateTime('1970-01-01 10:10:10', 'UTC')),
|
||||
toStartOfWeek(toDateTime64('1970-01-01 10:10:10.123', 3, 'UTC')),
|
||||
toStartOfWeek(toDate32('1930-01-01')),
|
||||
toStartOfWeek(toDate32('2151-01-01')),
|
||||
toStartOfWeek(toDateTime64('1930-01-01 12:12:12.123', 3)),
|
||||
|
Loading…
Reference in New Issue
Block a user