Am 19.07.22 um 16:20 schrieb Tom Lane:
>
> So I withdraw my original position. These functions should just
> shuffle or select in the array's first dimension, preserving
> subarrays. Or else be lazy and reject more-than-one-D arrays;
> but it's probably not that hard to handle them.
>
Here is a patch with dimension aware array_shuffle() and array_sample().
If you think array_flatten() is desirable, i can take a look at it.
Maybe a second parameter would be nice to specify the target dimension:
select array_flatten(array[[[1,2],[3,4]],[[5,6],[7,8]]], 1);
-------------------
{1,2,3,4,5,6,7,8}
select array_flatten(array[[[1,2],[3,4]],[[5,6],[7,8]]], 2);
-----------------------
{{1,2,3,4},{5,6,7,8}}
Martin