Re: New function normal_rand_array function to contrib/tablefunc.

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, 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-04 21:21:10
Message-ID: CAEZATCX9SeH-q8zaqjh8m=m7_RYFcLJLRSZ8fVvB1MbZ7pQQMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 4 Nov 2024 at 14:46, Aleksander Alekseev
<aleksander(at)timescale(dot)com> wrote:
>
> Any reason not to have an interface as simple and straightforward as
> this:
>
> =# 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?

The other question is whether it's an array function or a random
function. I.e., should it be listed in "Table 9.55. Array Functions",
in which case the name array_random() makes sense, or should it be
listed in "Table 9.6. Random Functions", in which case it should
probably be called random_array(). I think the latter makes more
sense, since it's a function that generates random values, more
similar to the random(min, max) functions. Also I think it's more
useful if it shares the same PRNG, controlled by setseed(), and it
makes sense to group all such functions together.

Regards,
Dean

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthias van de Meent 2024-11-04 21:57:58 Re: Adding skip scan (including MDAM style range skip scan) to nbtree
Previous Message Sam Gabrielsson 2024-11-04 21:16:37 Re: SQL:2011 application time