Merge pull request #4614 from proller/fix23

Fix bug in arrayEnumerateRanked
This commit is contained in:
alexey-milovidov 2019-03-07 02:34:31 +03:00 committed by GitHub
commit 5411920ee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -47,7 +47,7 @@ ArraysDepths getArraysDepths(const ColumnsWithTypeAndName & arguments)
UInt64 value = static_cast<const ColumnConst &>(*depth_column).getValue<UInt64>();
if (!value)
throw Exception("Incorrect arguments for function arrayEnumerateUniqRanked or arrayEnumerateDenseRanked: depth ("
+ std::to_string(value) + ") cannot be 0.",
+ std::to_string(value) + ") cannot be less or equal 0.",
ErrorCodes::BAD_ARGUMENTS);
if (i == 0)
@ -60,6 +60,11 @@ ArraysDepths getArraysDepths(const ColumnsWithTypeAndName & arguments)
throw Exception("Incorrect arguments for function arrayEnumerateUniqRanked or arrayEnumerateDenseRanked: depth ("
+ std::to_string(value) + ") for missing array.",
ErrorCodes::BAD_ARGUMENTS);
if (value > prev_array_depth)
throw Exception(
"Arguments for function arrayEnumerateUniqRanked/arrayEnumerateDenseRanked incorrect: depth="
+ std::to_string(value) + " for array with depth=" + std::to_string(prev_array_depth) + ".",
ErrorCodes::BAD_ARGUMENTS);
depths.emplace_back(value);
}

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 }
@ -172,3 +172,11 @@ SELECT arrayEnumerateUniqRanked([1,2], 1, 3, [4], 5); -- { serverError 36 }
SELECT arrayEnumerateDenseRanked([[[[[[[[[[42]]]]]]]]]]);
SELECT arrayEnumerateUniqRanked('wat', [1,2]); -- { serverError 170 }
SELECT arrayEnumerateUniqRanked(1, [1,2], 'boom'); -- { serverError 170 }
SELECT arrayEnumerateDenseRanked(['\0'], -8363126); -- { serverError 170 }
SELECT arrayEnumerateDenseRanked(-10, ['\0'], -8363126); -- { serverError 170 }
SELECT arrayEnumerateDenseRanked(1, ['\0'], -8363126); -- { serverError 170 }
SELECT arrayEnumerateDenseRanked(-101, ['\0']); -- { serverError 170 }
SELECT arrayEnumerateDenseRanked(1.1, [10,20,10,30]); -- { serverError 170 }
SELECT arrayEnumerateDenseRanked([10,20,10,30], 0.4); -- { serverError 170 }
SELECT arrayEnumerateDenseRanked([10,20,10,30], 1.8); -- { serverError 170 }
SELECT arrayEnumerateUniqRanked(1, [], 1000000000); -- { serverError 36 }