Skip to content

Spread Functionality Added to the Rel Standard Library

digital-book

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

Even

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.

// read query
 
def R = {"Flamingo"; "Cat"; "Dog"}
 
def output = spread[:even, R, 10]

Relation:

Ratio

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.

// read query
 
def R = {("Flamingo", 1); ("Cat", 2); ("Dog", 3)}
 
def output = spread[:ratio, R, decimal[64, 2, 10.0]]

Relation:

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

Get Started!

Start your journey with RelationalAI today! Sign up to receive our newsletter, invitations to exclusive events, and customer case studies.

The information you provide will be used in accordance with the terms of our Privacy Policy. By submitting this form, you consent to allow RelationalAI to store and process the personal information submitted above to provide you the content requested.