Let’s say I have a dataset of colors, each with a number:
{1,Blue},{2,Red},{3,Green},{4,Yellow}.. etc
I want a column in my schema to have a list of unique random colors from that set.
ex: "Green,Yellow,Blue"
I could do this without the dataset, that would look like a formula column with this content:
['Blue', 'Red', 'Green', 'Yellow'].sample(random(1,4)).shuffle.join(',')
But my dataset is large, so i don’t want to manage the list in the schema.
Is there a method to get all the values of a dataset column as an array? Or maybe Is there a way to use from_datasource using a variable instead of a column?.. maybe something like this:
(0..50).to_a.shuffle.map! { |e| e == from_dataset("colors", "color", color_id: e) }.take(random(0,3)).join(',')