From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Andy Fan <zhihuifan1213(at)163(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(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 14:46:46 |
Message-ID: | CAJ7c6TO8N4hE7zFKrf90uyS1ct+UCEzYuzq6=pG=e4eZykwRgQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
> I played with patch v3. All in all it seems to be in good shape.
>
> I wonder though whether tablefunc extension is the right place for the
> function. To me it seems to be as useful as array_shuffle().
>
> Personally I would name the function array_rand() in order to be
> consistent with the rest of array_* functions [1].
>
> I would also replace `minlen` and `maxlen` arguments with a single
> `len` argument because the same result (although more slowly) can be
> achieved like this:
>
> SELECT trim_array(arr, random(0,3)) FROM rand_array(10, 3, 3, 50::int,
> 80::int) as arr;
>
> This could be just a bike-shedding though. Does anyone feel necessary
> to second any of these nitpicks?
>
> [1]: https://www.postgresql.org/docs/current/functions-array.html
On second thought, is there really much value in returning a setof?
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}
...
```
? Or maybe I'm missing something?
--
Best regards,
Aleksander Alekseev
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2024-11-04 14:58:53 | Re: Pgoutput not capturing the generated columns |
Previous Message | Bruce Momjian | 2024-11-04 14:41:06 | pg_dump --no-comments confusion |