Re: [PATCH] Introduce array_shuffle() and array_sample() - Mailing list pgsql-hackers

From Martin Kalcher
Subject Re: [PATCH] Introduce array_shuffle() and array_sample()
Date
Msg-id 7e7cf274-09cb-00cf-1715-979f011e40b0@aboutsource.net
Whole thread Raw
In response to Re: [PATCH] Introduce array_shuffle() and array_sample()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCH] Introduce array_shuffle() and array_sample()
List pgsql-hackers
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
Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: postgres_fdw: using TABLESAMPLE to collect remote sample
Next
From: Tom Lane
Date:
Subject: Re: pg_parameter_aclcheck() and trusted extensions