relationalai.dsl.Expression
class ExpressionExpression 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
Section titled “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 FredThe following operators are supported:
- Add (
+) - Subtract (
-) - Multiply (
*) - Power (
**) - Divide (
/) - Floor divide (
//) - Modulo (
%) - Equal (
==) - Not equal (
!=) - Greater than (
>) - Greater than or equal (
>=) - Less than (
<) - Less than or equal (
<=)