Available since 15.1 Southside release
Build an expression that applies the round function to the given expression.
Code
Groovy
def qapi = api.queryApi()
def t1 = qapi.tables().products()
def products = qapi.source(t1, [t1.sku(), t1.Costs, t1.label()], t1.Costs.greaterThan(40))
.take(5)
.stream { it.collect { it } }
return products.collect { row ->
[
ProductID : row.sku,
Label : row.label,
Costs : row.Costs,
"Rounded Costs" : Math.round(row.Costs)
]
}
Result
|
ProductID |
Label |
Costs |
Rounded Costs |
|---|---|---|---|
|
B-0029 |
21st Amendment IPA (2006) |
46.84 |
47 |
|
B-0072 |
35 K |
41.57 |
42 |
|
B-0090 |
Alaskan Amber |
40.63 |
41 |
|
P-0002 |
Another Product |
150 |
150 |
|
B-0077 |
Bloody Show |
42.26 |
42 |