Re: [PATCH] Introduce array_shuffle() and array_sample()
От | Aleksander Alekseev |
---|---|
Тема | Re: [PATCH] Introduce array_shuffle() and array_sample() |
Дата | |
Msg-id | CAJ7c6TNeJYLVAGSEHYizaR+j=7UOHHrG=supAk-gU_a9Hx76_A@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [PATCH] Introduce array_shuffle() and array_sample() (Martin Kalcher <martin.kalcher@aboutsource.net>) |
Список | pgsql-hackers |
Hi Martin, I didn't look at the code yet but I very much like the idea. Many thanks for working on this! It's a pity your patch was too late for the July commitfest. In September, please keep an eye on cfbot [1] to make sure your patch applies properly. > As Tom's investigation showed, there is no consensus in the code if > multi-dimensional arrays are treated as arrays-of-arrays or not. We need > to decide what should be the correct treatment. Here are my two cents. From the user perspective I would expect that by default a multidimensional array should be treated as an array of arrays. So for instance: ``` array_shuffle([ [1,2], [3,4], [5,6] ]) ``` ... should return something like: ``` [ [3,4], [1,2], [5,6] ] ``` Note that the order of the elements in the internal arrays is preserved. However, I believe there should be an optional argument that overrides this behavior. For instance: ``` array_shuffle([ [1,2], [3,4], [5,6] ], depth => 2) ``` BTW, while on it, shouldn't we add similar functions for JSON and/or JSONB? Or is this going to be too much for a single discussion? [1]: http://cfbot.cputube.org/ -- Best regards, Aleksander Alekseev
В списке pgsql-hackers по дате отправления: