Fix bug in arrayEnumerateRanked

This commit is contained in:
proller 2019-03-06 20:19:26 +03:00
parent a233b93b6a
commit 9159d602f5
2 changed files with 7 additions and 3 deletions

View File

@ -51,11 +51,11 @@ ArraysDepths getArraysDepths(const ColumnsWithTypeAndName & arguments)
if (depth_column && depth_column->isColumnConst())
{
auto value = depth_column->getUInt(0);
if (!value)
auto value = depth_column->getInt(0);
if (value <= 0)
throw Exception(
"Arguments for function arrayEnumerateUniqRanked/arrayEnumerateDenseRanked incorrect: depth ("
+ std::to_string(value) + ") cant be 0.",
+ std::to_string(value) + ") cant be less or equal 0.",
ErrorCodes::BAD_ARGUMENTS);
if (i == 0)

View File

@ -172,3 +172,7 @@ SELECT arrayEnumerateUniqRanked([1,2], 1, 3, [4], 5); -- { serverError 36 }
SELECT arrayEnumerateDenseRanked([[[[[[[[[[42]]]]]]]]]]);
SELECT arrayEnumerateUniqRanked('wat', [1,2]); -- { serverError 48 }
SELECT arrayEnumerateUniqRanked(1, [1,2], 'boom'); -- { serverError 48 }
SELECT arrayEnumerateDenseRanked(['\0'], -8363126); -- { serverError 36 }
SELECT arrayEnumerateDenseRanked(-10, ['\0'], -8363126); -- { serverError 36 }
SELECT arrayEnumerateDenseRanked(1, ['\0'], -8363126); -- { serverError 36 }
SELECT arrayEnumerateDenseRanked(-101, ['\0']); -- { serverError 36 }