ray.data.expressions.DownloadExpr.struct#

property DownloadExpr.struct: _StructNamespace#

Access struct operations for this expression.

Returns:

A _StructNamespace that provides struct-specific operations.

Example

>>> from ray.data.expressions import col
>>> import ray
>>> import pyarrow as pa
>>> ds = ray.data.from_arrow(pa.table({
...     "user": pa.array([
...         {"name": "Alice", "age": 30}
...     ], type=pa.struct([
...         pa.field("name", pa.string()),
...         pa.field("age", pa.int32())
...     ]))
... }))
>>> ds = ds.with_column("age", col("user").struct["age"])  # by name
>>> ds = ds.with_column("name", col("user").struct.field_by_index(0))  # by index
>>> ds = ds.with_column("name2", col("user").struct[0])  # bracket by index