ray.data.expressions.Expr#

class ray.data.expressions.Expr[source]#

Bases: ABC

Base class for all expression nodes.

This is the abstract base class that all expression types inherit from. It provides operator overloads for building complex expressions using standard Python operators.

Expressions form a tree structure where each node represents an operation or value. The tree can be evaluated against data batches to compute results.

Example

>>> from ray.data.expressions import col, lit
>>> # Create an expression tree: (col("x") + 5) * col("y")
>>> expr = (col("x") + lit(5)) * col("y")
>>> # This creates a BinaryExpr with operation=MUL
>>> # left=BinaryExpr(op=ADD, left=ColumnExpr("x"), right=LiteralExpr(5))
>>> # right=ColumnExpr("y")

Note

This class should not be instantiated directly. Use the concrete subclasses like ColumnExpr, LiteralExpr, etc.

DeveloperAPI: This API may change across minor Ray releases.

Methods

structurally_equals

Compare two expression ASTs for structural equality.