Join us at Snowflake Summit June 26-29 in Las Vegas!

Spread Functionality Added to the Rel Standard Library

Huda Nassar

09 October 2021

less than a minute read

We are excited to announce that we now support a spread functionality implemented natively in Rel. We support two main strategies: even and ratio.


For the even strategy, we spread an equal number of units to all elements in a relation, and when we can no longer have equal amounts, we spread the remaining singletons in order starting with the first element in a lexicographic order.

def R = {"Flamingo"; "Cat"; "Dog"}

def output = spread[:even, R, 10]




For the ratio strategy, we spread a number proportional to the weight corresponding to each element in a relation (provided by the user). Remaining singletons are spread in order after the elements are sorted according to their weights.

def R = {("Flamingo", 1); ("Cat", 2); ("Dog", 3)}

def output = spread[:ratio, R, decimal[64, 2, 10.0]]



Notice, for decimal numbers the digit precision (here: 2) is preserved during the spread.

Related Posts

Get Early Access

Join our community, keep up to date with the latest developments in our monthly newsletter, and get early access to RelationalAI.