Re: [PATCH] Generate random dates/times in a specified range
От | Dean Rasheed |
---|---|
Тема | Re: [PATCH] Generate random dates/times in a specified range |
Дата | |
Msg-id | CAEZATCWugZ5PESq10TJCQUgs68S2aLhSzdgMNuiLSmNqd7R5sQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [PATCH] Generate random dates/times in a specified range (Robert Treat <rob@xzilla.net>) |
Список | pgsql-hackers |
On Tue, 15 Jul 2025 at 04:49, Robert Treat <rob@xzilla.net> wrote: > > On Mon, Jul 14, 2025 at 3:21 AM Dean Rasheed <dean.a.rasheed@gmail.com> wrote: > > > > But it's completely trivial to emulate random(min_date, max_date), just by doing > > > > min_date + random(0, max_date - min_date) > > > > Is it really worth adding a core function for that? > > I feel like this is a very similar argument against what was > ultimately the addition of timestamp based generate_series functions, > and similarly I think adding these in would be a rather useful > improvement for users, though like generate_series, we don't need to > hit every different data type (no one should ever generate a random > timetz for instance). Right, and for generate_series() we didn't add a variant for type date. In fact, we explicitly documented how a sequence of dates can be generated using the date-plus-integer operator. In fact, I think generate_series() sets a good precedent, and I could get behind a proposal that adds new random() functions with the same signatures as the timestamp-based generate_series() functions. In particular, I think that it's quite likely that if I wanted a random timestamp in some range, I would want some specified precision, like say 'hour' or 'day', and not a timestamp with some random number of microseconds. (In a similar vein, it might be useful to add an optional "step" parameter to the random integer/numeric functions, but that's really a separate proposal.) Regards, Dean
В списке pgsql-hackers по дате отправления: