Re: array_random - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: array_random
Date
Msg-id CAJ7c6TMaEstEeHx-6H0T4zqoO+5=iCVma6YCt0btmLxFRFbYew@mail.gmail.com
Whole thread Raw
In response to Re: array_random  (jian he <jian.universality@gmail.com>)
List 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?



pgsql-hackers by date:

Previous
From: Rahila Syed
Date:
Subject: Re: Small optimization with expanding dynamic hash table
Next
From: Dean Rasheed
Date:
Subject: Re: Fix replica identity checks for MERGE command on published table.