Forbid implicit cast of numbers to intervals with the string argument

This commit is contained in:
Nikolay Degterinsky 2023-10-30 18:03:35 +01:00 committed by GitHub
parent 5067fb342f
commit 58b188e880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -812,6 +812,7 @@ class FunctionBinaryArithmetic : public IFunction
const DataTypePtr & type_time = first_arg_is_date_or_datetime_or_string ? type0 : type1;
const DataTypePtr & type_interval = first_arg_is_date_or_datetime_or_string ? type1 : type0;
bool first_or_second_arg_is_string = isString(type0) || isString(type1);
bool interval_is_number = isNumber(type_interval);
const DataTypeInterval * interval_data_type = nullptr;
@ -822,6 +823,10 @@ class FunctionBinaryArithmetic : public IFunction
if (!interval_data_type)
return {};
}
else if (first_or_second_arg_is_string)
{
return {};
}
if (second_arg_is_date_or_datetime_or_string && is_minus)
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Wrong order of arguments for function {}: "