maximum()#
relationalai.std
#maximum(arg1: Any, arg2: Any, *args: Any) -> Expression
Returns the maximum of the arguments. Must be used in a rule or query context.
Parameters#
Name | Type | Description |
---|---|---|
arg1 | Any | The first argument. |
arg2 | Any | The second argument. |
*args | Any | Additional arguments. |
Returns#
An Expression
object.
Example#
Use maximum()
to return the maximum of two or more arguments:
#import relationalai as rai
from relationalai.std import alias, maximum
model = rai.Model("MyModel")
Point = model.Type("Point")
with model.rule():
Point.add(x=1, y=2)
Point.add(x=4, y=3)
with model.query() as select:
point = Point()
max_coord = maximum(point.x, point.y)
response = select(point.x, point.y, alias(max_coord, "max"))
print(response.results)
# x y max
# 0 1 2 2
# 1 4 3 4