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: 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:34:01
Message-ID: CAJ7c6TNO_a0RZdV68TzaxRur1=Hcuxo7zyYGnxCMUnbfChyAZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi everyone,

> >> Thanks for the detailed feedback! Here is the rebased version.
> >>
> >
> > I took another look at this and I think it's in reasonable shape.
> >
> > I'm attaching an update, rebasing it on top of 9be4e5d293.
>
> Thank you Dean.
>
> > Also it was missing a required update to the meson.build file --
> > that's the immediate cause of the other cfbot failures.
>
> OK, great to know this one, I should have paid more attention to cfbot.
>
> > The rest is just cosmetic tidying up, fixing indentation, tweaking
> > comments, and the like. I also hacked on the docs a bit -- the
> > synopsis only listed one of the new function signatures for some
> > reason. After fixing that, I think it's sufficient to just list one
> > usage example.
>
> That looks better now, more concise and expressive sentences.

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

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2024-11-04 14:41:06 pg_dump --no-comments confusion
Previous Message Tender Wang 2024-11-04 14:31:23 Fix a typo in the comment of gistdoinsert()