Fix - allow empty tz in exp like toStartOf*(today())

This commit is contained in:
bharatnc 2020-09-25 11:03:16 -07:00
parent 5d8de1f65d
commit 5c8c636cf1

View File

@ -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);