Re: New function normal_rand_array function to contrib/tablefunc.

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Andy Fan <zhihuifan1213(at)163(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Subject: Re: New function normal_rand_array function to contrib/tablefunc.
Date: 2024-11-05 17:35:31
Message-ID: CAJ7c6TPw3tD3PJneqZdfmauqx8qW3yeLw7WY3NucNavjDzdpyA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> 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).

FWIW we have several array_* functions that deal only with the first
dimension of an array: array_shuffle(), array_sample() the recently
added array_reverse() [1], the currently discussed array_sort() [2].

I suggest implementing the function in several steps. First implement
random_array(min, max, len). It's straightforward and IMO will provide
the most value to the majority of the users.Then we can either add an
optional argument or a random_array_multidim() function. This can be
implemented and discussed as a separate patch. This approach would be
convenient for the author and the reviewers and also will allow us to
deliver value to the users sooner.

[1]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=49d6c7d8daba
[2]: https://commitfest.postgresql.org/50/5277/

--
Best regards,
Aleksander Alekseev

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Frédéric Yhuel 2024-11-05 17:36:47 doc: explain pgstatindex fragmentation
Previous Message Robert Haas 2024-11-05 17:30:42 meson vs. extension builds