Fix array index argument type check for JSONExtract* functions

This commit is contained in:
Márcio Martins 2022-10-31 15:02:08 +01:00
parent c33bd7794f
commit 399d024c2c
3 changed files with 5 additions and 1 deletions

View File

@ -191,7 +191,7 @@ private:
for (const auto i : collections::range(first_index_argument, first_index_argument + num_index_arguments))
{
const auto & column = columns[i];
if (!isString(column.type) && !isInteger(column.type))
if (!isString(column.type) && !isNativeInteger(column.type))
throw Exception{"The argument " + std::to_string(i + 1) + " of function " + String(function_name)
+ " should be a string specifying key or an integer specifying index, illegal type: " + column.type->getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};

View File

@ -253,3 +253,4 @@ e
u
v
--show error: type should be const string
--show error: index type should be integer

View File

@ -280,3 +280,6 @@ SELECT JSONExtractString(json, 's') FROM (SELECT arrayJoin(['{"s":"u"}', '{"s":"
SELECT '--show error: type should be const string';
SELECT JSONExtractKeysAndValues([], JSONLength('^?V{LSwp')); -- { serverError 44 }
WITH '{"i": 1, "f": 1.2}' AS json SELECT JSONExtract(json, 'i', JSONType(json, 'i')); -- { serverError 44 }
SELECT '--show error: index type should be integer';
SELECT JSONExtract('[]', JSONExtract('0', 'UInt256'), 'UInt256'); -- { serverError 43 }