mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Clamp the limit for arrayPartialShuffle
This commit is contained in:
parent
b0ba8c02be
commit
e1d281206f
@ -156,7 +156,10 @@ ColumnPtr FunctionArrayShuffleImpl<Traits>::executeGeneric(const ColumnArray & a
|
||||
if constexpr (Traits::has_limit)
|
||||
{
|
||||
if (limit)
|
||||
partial_shuffle(&permutation[current_offset], &permutation[next_offset], limit, rng);
|
||||
{
|
||||
const auto effective_limit = std::min(limit, next_offset - current_offset);
|
||||
partial_shuffle(&permutation[current_offset], &permutation[next_offset], effective_limit, rng);
|
||||
}
|
||||
else
|
||||
shuffle(&permutation[current_offset], &permutation[next_offset], rng);
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
[10,9,4,2,5,6,7,1,3,8]
|
||||
[10,9,4,2,5,6,7,1,8,3]
|
||||
[10,9,4,2,5,6,7,1,8,3]
|
||||
[10,9,4,2,5,6,7,1,8,3]
|
||||
[10.1,9,4,2,5,6,7,8,3,1]
|
||||
[9223372036854775808,9,4,2,5,6,7,8,3,1]
|
||||
[NULL,9,4,2,5,6,7,8,3,1]
|
||||
|
@ -47,6 +47,7 @@ SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,10], 4, 0xbad_cafe);
|
||||
SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,10], 8, 0xbad_cafe);
|
||||
SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,10], 9, 0xbad_cafe);
|
||||
SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,10], 10, 0xbad_cafe);
|
||||
SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,10], 100, 0xbad_cafe);
|
||||
SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,10.1], 4, 0xbad_cafe);
|
||||
SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,9223372036854775808], 4, 0xbad_cafe);
|
||||
SELECT arrayPartialShuffle([1,2,3,4,5,6,7,8,9,NULL], 4, 0xbad_cafe);
|
||||
|
Loading…
Reference in New Issue
Block a user