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]
Relation:
"Cat" | 4 |
"Dog" | 3 |
"Flamingo" | 3 |
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]]
Relation:
"Cat" | 3.33 |
"Dog" | 5.0 |
"Flamingo" | 1.67 |
Notice, for decimal numbers the digit precision (here: 2
) is preserved during the spread.
We are excited to announce worksheets, a new interface for submitting Rel queries. Worksheets allow you to develop blocks of Rel code and run them against a database. They can be shared with other users using their URLs.
Read MoreWe are excited to announce the support of varargs in Rel. You can use varargs to write more general code that works for multiple arities. Varargs can be useful when writing generic relations for common utilities.
Read MoreValue types help distinguish between different kinds of values, even though the underlying representation may be identical. Value types can be used to define other value types.
Read More