Skip to content

relationalai.std.maximum()

maximum(arg1: Any, arg2: Any, *args: Any) -> Expression

Returns the maximum of the arguments. Must be used in a rule or query context.

NameTypeDescription
arg1AnyThe first argument.
arg2AnyThe second argument.
*argsAnyAdditional arguments.

An Expression object.

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