ray.data.expressions.LiteralExpr#

class ray.data.expressions.LiteralExpr(value: Any)[source]#

Bases: Expr

Expression that represents a constant scalar value.

This expression type represents a literal value that will be broadcast to all rows when evaluated. The value can be any Python object.

Parameters:

value – The constant value to represent

Example

>>> from ray.data.expressions import lit
>>> import numpy as np
>>> # Create a literal value
>>> five = lit(5) # Creates LiteralExpr(value=5)
>>> name = lit("John") # Creates LiteralExpr(value="John")
>>> numpy_val = lit(np.int32(42)) # Creates LiteralExpr with numpy type

DeveloperAPI: This API may change across minor Ray releases.

Methods

alias

Rename the expression.

is_in

Check if the expression value is in a list of values.

is_not_null

Check if the expression value is not null.

is_null

Check if the expression value is null.

not_in

Check if the expression value is not in a list of values.

to_pyarrow

Convert this Ray Data expression to a PyArrow compute expression.

Attributes

list

Access list operations for this expression.

name

Get the name associated with this expression.

str

Access string operations for this expression.

struct

Access struct operations for this expression.

value

data_type