Better fix

This commit is contained in:
proller 2019-03-06 22:19:21 +03:00
parent 9159d602f5
commit ee15cb237c
3 changed files with 16 additions and 5 deletions

View File

@ -71,17 +71,22 @@ ArraysDepths getArraysDepths(const ColumnsWithTypeAndName & arguments)
+ std::to_string(value) + ") for missing array.",
ErrorCodes::BAD_ARGUMENTS);
}
if (value > last_array_depth)
throw Exception(
"Arguments for function arrayEnumerateUniqRanked/arrayEnumerateDenseRanked incorrect: depth="
+ std::to_string(value) + " for array with depth=" + std::to_string(last_array_depth) + ".",
ErrorCodes::BAD_ARGUMENTS);
depths.emplace_back(value);
}
}
}
}
if (depths.size() < array_num)
{
depths.emplace_back(last_array_depth);
}
for (auto & depth : depths)
{
if (max_array_depth < depth)

View File

@ -178,3 +178,5 @@ arrayEnumerateUniq(a1, a2) =
[1,2]
[1,1]
[[[[[[[[[[1]]]]]]]]]]
[1,2,1,3]
[1,2,1,3]

View File

@ -145,11 +145,11 @@ SELECT arrayEnumerateUniqRanked(); -- { serverError 42 }
SELECT arrayEnumerateUniqRanked([]);
SELECT arrayEnumerateUniqRanked(1); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked(2,[]); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked(2,[],2); -- { serverError 190 }
SELECT arrayEnumerateUniqRanked(2,[],2); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked(2,[],[]); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked(2,[],[],3); -- { serverError 190 }
SELECT arrayEnumerateUniqRanked([],2); -- { serverError 190 }
SELECT arrayEnumerateUniqRanked([],2,[]); -- { serverError 190 }
SELECT arrayEnumerateUniqRanked(2,[],[],3); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked([],2); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked([],2,[]); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked(0,[],0); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked(0,0,0); -- { serverError 36 }
SELECT arrayEnumerateUniqRanked(1,1,1); -- { serverError 36 }
@ -176,3 +176,7 @@ 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 }
SELECT arrayEnumerateDenseRanked(1.1, [10,20,10,30]);
SELECT arrayEnumerateDenseRanked([10,20,10,30], 0.4); -- { serverError 36 }
SELECT arrayEnumerateDenseRanked([10,20,10,30], 1.8);
SELECT arrayEnumerateUniqRanked(1, [], 1000000000); -- { serverError 36 }