Expression#

relationalai
class Expression

Expression is a subclass of Producer that produces the results of aggregations and mathematical operations involving Producer objects. Must be used in a rule or query context.

Example#

You create an Expression object when you use an operator like > with a Producer object:

import relationalai as rai

model = rai.Model("people")
Person = model.Type("Person")

with model.rule():
   Person.add(name="Fred", age=39)
   Person.add(name="Wilma", age=36)

with model.query() as select:
    person = Person()
    # Restrict `person.age` to values strictly greater than 36
    # and return an `Expression` object.
    person.age > 36
    response = select(person.name)

print(response.results)
# Output:
#    name
# 0  Fred

The following operators are supported:

See Also#