Re: array_random

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>
Subject: Re: array_random
Date: 2025-07-08 08:45:44
Message-ID: CAJ7c6TMaEstEeHx-6H0T4zqoO+5=iCVma6YCt0btmLxFRFbYew@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> it seems not trivial to wrap up all the generated random values into a specific
> multi-dimensional array (more than 2 dimensions).
> for example, say we generated 24 random values and wanted to arrange them into a
> 3-dimensional array with shape [4, 3, 2].
> we can easily use:
> SELECT array_random(1, 6, array[4,3, 2]);
>
> of course, we can use plpgsql to do it, but the c function would be
> more convenient.
> does this make sense?

The proposed function seems to do two things at a time - generating
random values and transforming them into an array of desired
dimensions. Generally we try to avoid such interfaces. Can you think
of something like array_transform() / array_reshape() that takes an
arbitrary single-dimension array and modifies it?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2025-07-08 08:51:26 Re: Fix replica identity checks for MERGE command on published table.
Previous Message Rahila Syed 2025-07-08 08:32:50 Re: Small optimization with expanding dynamic hash table