Re: [PATCH] Introduce array_shuffle() and array_sample()

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [PATCH] Introduce array_shuffle() and array_sample()
Дата
Msg-id CAKFQuwZ9o3Nw5TVgPf9xeTc73ad=BYJjT9werq6ztp6Lb_FVHA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Introduce array_shuffle() and array_sample()  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH] Introduce array_shuffle() and array_sample()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, Jul 18, 2022 at 3:18 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Independently of the dimensionality question --- I'd imagined that
array_sample would select a random subset of the array elements
but keep their order intact.  If you want the behavior shown
above, you can do array_shuffle(array_sample(...)).  But if we
randomize it, and that's not what the user wanted, she has no
recourse.


And for those that want to know in what order those elements were chosen they have no recourse in the other setup.

I really think this function needs to grow an algorithm argument that can be used to specify stuff like ordering, replacement/without-replacement, etc...just some enums separated by commas that can be added to the call.

David J.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [PATCH] Introduce array_shuffle() and array_sample()
Следующее
От: Justin Pryzby
Дата:
Сообщение: Re: Commitfest Update