additional checks for empty tz for toStartOfMonth|Quarter|Year

This commit is contained in:
bharatnc 2020-09-04 20:15:37 -07:00
parent 8fd00ff77b
commit 25080f3a88
3 changed files with 10 additions and 1 deletions

View File

@ -54,7 +54,12 @@ std::string extractTimeZoneNameFromFunctionArguments(const ColumnsWithTypeAndNam
const DateLUTImpl & extractTimeZoneFromFunctionArguments(Block & block, const ColumnNumbers & arguments, size_t time_zone_arg_num, size_t datetime_arg_num)
{
if (arguments.size() == time_zone_arg_num + 1)
return DateLUT::instance(extractTimeZoneNameFromColumn(*block.getByPosition(arguments[time_zone_arg_num]).column));
{
std::string time_zone = extractTimeZoneNameFromColumn(*block.getByPosition(arguments[time_zone_arg_num]).column);
if (time_zone.empty())
throw Exception("Provided time zone must be non-empty and be a valid time zone", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
return DateLUT::instance(time_zone);
}
else
{
if (arguments.empty())

View File

@ -1,6 +1,7 @@
2017-12-31 00:00:00
2017-12-01
2017-10-01
2017-01-01
2017-12-31 05:10:00
2017-12-31 01:15:00
2017-12-31 01:00:00

View File

@ -7,6 +7,9 @@ SELECT toStartOfMonth(toDateTime('2017-12-31 00:00:00', 'UTC'), 'UTC'); -- succe
SELECT toStartOfQuarter(toDateTime('2017-12-31 00:00:00', 'UTC'), ''); -- {serverError 43}
SELECT toStartOfQuarter(toDateTime('2017-12-31 00:00:00', 'UTC'), 'UTC'); -- success
SELECT toStartOfYear(toDateTime('2017-12-31 00:00:00', 'UTC'), ''); -- {serverError 43}
SELECT toStartOfYear(toDateTime('2017-12-31 00:00:00', 'UTC'), 'UTC'); -- success
SELECT toStartOfTenMinutes(toDateTime('2017-12-31 00:00:00', 'UTC'), ''); -- {serverError 43}
SELECT toStartOfTenMinutes(toDateTime('2017-12-31 05:12:30', 'UTC'), 'UTC'); -- success