mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #15319 from bharatnc/ncb/fix-14509
Fix bug in queries like SELECT toStartOfDay(today())
This commit is contained in:
commit
6f3aab8f09
@ -71,7 +71,9 @@ public:
|
||||
if constexpr (std::is_same_v<ToDataType, DataTypeDateTime>)
|
||||
{
|
||||
std::string time_zone = extractTimeZoneNameFromFunctionArguments(arguments, 1, 0);
|
||||
if (time_zone.empty())
|
||||
/// only validate the time_zone part if the number of arguments is 2. This is mainly
|
||||
/// to accommodate functions like toStartOfDay(today()), toStartOfDay(yesterday()) etc.
|
||||
if (arguments.size() == 2 && time_zone.empty())
|
||||
throw Exception(
|
||||
"Function " + getName() + " supports a 2nd argument (optional) that must be non-empty and be a valid time zone",
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
|
@ -88,38 +88,37 @@ SELECT toStartOfWeek(N)
|
||||
"Date","2019-09-15"
|
||||
------------------------------------------
|
||||
SELECT toStartOfDay(N)
|
||||
|
||||
Code: 43: Function toStartOfDay supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
"DateTime","2019-09-16 00:00:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 00:00:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 00:00:00"
|
||||
------------------------------------------
|
||||
SELECT toStartOfHour(N)
|
||||
|
||||
Code: 43: Function toStartOfHour supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
Code: 43: Illegal type Date of argument for function toStartOfHour.
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:00:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:00:00"
|
||||
------------------------------------------
|
||||
SELECT toStartOfMinute(N)
|
||||
|
||||
Code: 43: Function toStartOfMinute supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
Code: 43: Illegal type Date of argument for function toStartOfMinute.
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:20:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:20:00"
|
||||
------------------------------------------
|
||||
SELECT toStartOfFiveMinute(N)
|
||||
|
||||
Code: 43: Function toStartOfFiveMinute supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
Code: 43: Illegal type Date of argument for function toStartOfFiveMinute.
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:20:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:20:00"
|
||||
------------------------------------------
|
||||
SELECT toStartOfTenMinutes(N)
|
||||
|
||||
Code: 43: Function toStartOfTenMinutes supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
Code: 43: Illegal type Date of argument for function toStartOfTenMinutes.
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:20:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:20:00"
|
||||
------------------------------------------
|
||||
SELECT toStartOfFifteenMinutes(N)
|
||||
|
||||
Code: 43: Function toStartOfFifteenMinutes supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
Code: 43: Illegal type Date of argument for function toStartOfFifteenMinutes.
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:15:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:15:00"
|
||||
------------------------------------------
|
||||
@ -167,7 +166,7 @@ Code: 43: Illegal type Date of argument for function date_trunc.
|
||||
------------------------------------------
|
||||
SELECT toTime(N)
|
||||
|
||||
Code: 43: Function toTime supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
Code: 43: Illegal type Date of argument for function toTime.
|
||||
"DateTime('Europe/Minsk')","1970-01-02 19:20:11"
|
||||
"DateTime('Europe/Minsk')","1970-01-02 19:20:11"
|
||||
------------------------------------------
|
||||
@ -233,7 +232,7 @@ SELECT toYearWeek(N)
|
||||
------------------------------------------
|
||||
SELECT timeSlot(N)
|
||||
|
||||
Code: 43: Function timeSlot supports a 2nd argument (optional) that must be non-empty and be a valid time zone.
|
||||
Code: 43: Illegal type Date of argument for function timeSlot.
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:00:00"
|
||||
"DateTime('Europe/Minsk')","2019-09-16 19:00:00"
|
||||
------------------------------------------
|
||||
|
@ -21,3 +21,7 @@ SELECT toStartOfHour(toDateTime('2017-12-31 01:59:00', 'UTC'), 'UTC'); -- succes
|
||||
|
||||
SELECT toStartOfMinute(toDateTime('2017-12-31 00:00:00', 'UTC'), ''); -- {serverError 43}
|
||||
SELECT toStartOfMinute(toDateTime('2017-12-31 00:01:30', 'UTC'), 'UTC'); -- success
|
||||
|
||||
-- special case - allow empty time_zone when using functions like today(), yesterday() etc.
|
||||
SELECT toStartOfDay(today()) FORMAT Null; -- success
|
||||
SELECT toStartOfDay(yesterday()) FORMAT Null; -- success
|
||||
|
Loading…
Reference in New Issue
Block a user