diff --git a/dbms/src/Functions/arrayEnumerateRanked.cpp b/dbms/src/Functions/arrayEnumerateRanked.cpp index 8341bae97bc..705d92ecd19 100644 --- a/dbms/src/Functions/arrayEnumerateRanked.cpp +++ b/dbms/src/Functions/arrayEnumerateRanked.cpp @@ -47,7 +47,7 @@ ArraysDepths getArraysDepths(const ColumnsWithTypeAndName & arguments) UInt64 value = static_cast(*depth_column).getValue(); 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); } diff --git a/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql b/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql index 0557f4adf85..d622b1acd76 100644 --- a/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql +++ b/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql @@ -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 }