Skip to content

[Data] Compute Expressions - Expr Arithmetic#59678

Merged
richardliaw merged 3 commits intoray-project:masterfrom
zzchun:arithmatic-expr
Dec 30, 2025
Merged

[Data] Compute Expressions - Expr Arithmetic#59678
richardliaw merged 3 commits intoray-project:masterfrom
zzchun:arithmatic-expr

Conversation

@zzchun
Copy link
Contributor

@zzchun zzchun commented Dec 26, 2025

Description

Completing the Expr Arithmetic operations: negate, sign, power, abs

import ray
from ray.data import from_items
from ray.data.expressions import col

ds = from_items([{"x": 5}, {"x": 2}, {"x": 0}])
for row in ds.iter_rows():
    print(row)

x_expr = col("x")

ds = ds.with_column("x_negate", x_expr.negate())

ds = ds.with_column("x_sign", x_expr.sign())

ds = ds.with_column("x_power", x_expr.power(2))

ds = ds.with_column("x_abs", x_expr.abs())

for row in ds.iter_rows():
    print(row)

Related issues

Related to #58674

@zzchun zzchun requested a review from a team as a code owner December 26, 2025 14:00
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several new arithmetic helper expressions (negate, sign, power, abs) to ray.data.expressions.Expr, along with corresponding unit tests. The implementation is clean and follows the existing pattern for PyArrow compute function wrappers. The tests are well-structured and cover the new functionality. I have a couple of suggestions to improve safety and code clarity.

Completing the Expr Arithmetic operations: negate, sign, power, abs

Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: will <zzchun8@gmail.com>
@ray-gardener ray-gardener bot added data Ray Data-related issues community-contribution Contributed by the community labels Dec 26, 2025
@goutamvenkat-anyscale goutamvenkat-anyscale added the go add ONLY when ready to merge, run all tests label Dec 29, 2025
@zzchun
Copy link
Contributor Author

zzchun commented Dec 30, 2025

Hi @richardliaw , could you please review this PR when you have a moment? Thanks!

@richardliaw richardliaw merged commit 48961b8 into ray-project:master Dec 30, 2025
7 checks passed
AYou0207 pushed a commit to AYou0207/ray that referenced this pull request Jan 13, 2026
## Description

Completing the Expr Arithmetic operations: negate, sign, power, abs

```
import ray
from ray.data import from_items
from ray.data.expressions import col

ds = from_items([{"x": 5}, {"x": 2}, {"x": 0}])
for row in ds.iter_rows():
    print(row)

x_expr = col("x")

ds = ds.with_column("x_negate", x_expr.negate())

ds = ds.with_column("x_sign", x_expr.sign())

ds = ds.with_column("x_power", x_expr.power(2))

ds = ds.with_column("x_abs", x_expr.abs())

for row in ds.iter_rows():
    print(row)
```

## Related issues

Related to ray-project#58674

---------

Signed-off-by: will <zzchun8@gmail.com>
Co-authored-by: Goutam <goutam@anyscale.com>
Signed-off-by: jasonwrwang <jasonwrwang@tencent.com>
lee1258561 pushed a commit to pinterest/ray that referenced this pull request Feb 3, 2026
## Description

Completing the Expr Arithmetic operations: negate, sign, power, abs

``` 
import ray
from ray.data import from_items
from ray.data.expressions import col

ds = from_items([{"x": 5}, {"x": 2}, {"x": 0}])
for row in ds.iter_rows():
    print(row)

x_expr = col("x")

ds = ds.with_column("x_negate", x_expr.negate())

ds = ds.with_column("x_sign", x_expr.sign())

ds = ds.with_column("x_power", x_expr.power(2))

ds = ds.with_column("x_abs", x_expr.abs())

for row in ds.iter_rows():
    print(row)
```

## Related issues

Related to ray-project#58674

---------

Signed-off-by: will <zzchun8@gmail.com>
Co-authored-by: Goutam <goutam@anyscale.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
## Description

Completing the Expr Arithmetic operations: negate, sign, power, abs

```
import ray
from ray.data import from_items
from ray.data.expressions import col

ds = from_items([{"x": 5}, {"x": 2}, {"x": 0}])
for row in ds.iter_rows():
    print(row)

x_expr = col("x")

ds = ds.with_column("x_negate", x_expr.negate())

ds = ds.with_column("x_sign", x_expr.sign())

ds = ds.with_column("x_power", x_expr.power(2))

ds = ds.with_column("x_abs", x_expr.abs())

for row in ds.iter_rows():
    print(row)
```

## Related issues

Related to ray-project#58674

---------

Signed-off-by: will <zzchun8@gmail.com>
Co-authored-by: Goutam <goutam@anyscale.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
## Description

Completing the Expr Arithmetic operations: negate, sign, power, abs

```
import ray
from ray.data import from_items
from ray.data.expressions import col

ds = from_items([{"x": 5}, {"x": 2}, {"x": 0}])
for row in ds.iter_rows():
    print(row)

x_expr = col("x")

ds = ds.with_column("x_negate", x_expr.negate())

ds = ds.with_column("x_sign", x_expr.sign())

ds = ds.with_column("x_power", x_expr.power(2))

ds = ds.with_column("x_abs", x_expr.abs())

for row in ds.iter_rows():
    print(row)
```

## Related issues

Related to ray-project#58674

---------

Signed-off-by: will <zzchun8@gmail.com>
Co-authored-by: Goutam <goutam@anyscale.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants