Add missing check for argument type

This commit is contained in:
Salvatore Mesoraca 2023-04-18 18:17:26 +02:00
parent d65f98ea25
commit 5f589e20a3
No known key found for this signature in database
GPG Key ID: 0567E50A25403074
3 changed files with 12 additions and 0 deletions

View File

@ -127,6 +127,15 @@ namespace
if (args_size == 3)
{
if ((type_x->isValueRepresentedByNumber() != type_arr_to_nested->isValueRepresentedByNumber())
|| (isString(type_x) != isString(type_arr_to_nested)))
throw Exception(
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Function {} has signature: "
"transform(T, Array(T), Array(U), U) -> U; "
"or transform(T, Array(T), Array(T)) -> T; where T and U are types.",
getName());
auto ret = tryGetLeastSupertype(DataTypes{type_arr_to_nested, type_x});
if (!ret)
throw Exception(

View File

@ -69,3 +69,4 @@ other
2100
2200
2900
----

View File

@ -21,3 +21,5 @@ SELECT '----';
SELECT transform(number, [2, 4, 6], [2900, 2000, 2100], 2200) as x FROM numbers(10) GROUP BY x;
SELECT '#1';
SELECT transform(number, [2, 4, 6], [2900, 2000, 2100], materialize(2200)) as x FROM numbers(10) GROUP BY x;
SELECT '----';
SELECT transform(number, [1], [null]) FROM system.numbers LIMIT 1; -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }