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