Re: New function normal_rand_array function to contrib/tablefunc.
От | Dean Rasheed |
---|---|
Тема | Re: New function normal_rand_array function to contrib/tablefunc. |
Дата | |
Msg-id | CAEZATCWCOCQQe2vDt2T0whFP09RR=OSrvqYE2Y631mcL98m1eg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: New function normal_rand_array function to contrib/tablefunc. (Aleksander Alekseev <aleksander@timescale.com>) |
Ответы |
Re: New function normal_rand_array function to contrib/tablefunc.
|
Список | pgsql-hackers |
On Tue, 5 Nov 2024 at 15:23, Aleksander Alekseev <aleksander@timescale.com> wrote: > > > > =# SELECT array_random(1, 10, random(0, 3)) FROM generate_series( ... ) > > > {5} > > > {1, 3, 8} > > > {7, 6} > > > ... > > > > Yeah, that looks like a neater API. > > > > Something that bothers me somewhat is that it's completely trivial for > > the user to write such a function for themselves, so is it really > > useful enough to include in core? > > I think it would be useful. Many users don't bother writing C > extensions for tasks like this. So at least our implementation is > going to be faster. > If we are going to add such a function to core, then I think we should make it consistent and at least as flexible as the other array functions, and support multi-dimensional arrays with optional non-default lower-bounds, like array_fill(). I.e., something like: random_array(min int, max int, dims int[] [, lbounds int[]]) -> int[] Returns an array filled with random values in the range min <= x <= max, having dimensions of the lengths specified by dims. The optional lbounds argument supplies lower-bound values for each dimension (which default to all 1). Regards, Dean
В списке pgsql-hackers по дате отправления: