Skip to content

[Data] Compute Expressions-Expr Logarithmic#59549

Merged
richardliaw merged 2 commits intoray-project:masterfrom
myandpr:compute-expressions-expr-Logarithmic
Dec 23, 2025
Merged

[Data] Compute Expressions-Expr Logarithmic#59549
richardliaw merged 2 commits intoray-project:masterfrom
myandpr:compute-expressions-expr-Logarithmic

Conversation

@myandpr
Copy link
Member

@myandpr myandpr commented Dec 18, 2025

Description

Completing the Expr (direct) Logarithmic operations (ln, log10, log2, exp)

test for example:

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

ray.init(include_dashboard=False, ignore_reinit_error=True)

ds = from_items([
    {"x": 1.1},
    {"x": 2.5},
    {"x": 3.7},
])

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

x_expr = col("x")

hasattr(x_expr, "ln")
ds = ds.with_column("x_ln", x_expr.ln())

hasattr(x_expr, "log10")
ds = ds.with_column("x_log10", x_expr.log10())

hasattr(x_expr, "log2")
ds = ds.with_column("x_log2", x_expr.log2())

hasattr(x_expr, "exp")
ds = ds.with_column("x_exp", x_expr.exp())

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

Related issues

Related to #58674

Related PR: #59295

Additional information

Signed-off-by: yaommen <myanstu@163.com>
@myandpr myandpr requested a review from a team as a code owner December 18, 2025 15:33
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 adds logarithmic and exponential functions (ln, log10, log2, exp) to Ray Data expressions, which is a great addition. The implementation is clean and follows the existing pattern for wrapping PyArrow compute functions. The tests are also well-structured. I've found one important issue regarding the return type inference for these new functions when applied to integer columns, which could lead to incorrect schemas. I've provided a suggestion to fix this. I also recommended enhancing the tests to cover integer inputs to verify the fix and improve robustness. Overall, this is a solid contribution.

expected_fn,
):
"""Test logarithmic and exponential expressions."""
values = [1.0, math.e, 10.0, 4.0]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current test cases only cover floating-point inputs. The issue I pointed out in expressions.py regarding return type inference is most apparent with integer inputs. To ensure the fix is properly validated and to prevent future regressions, it would be beneficial to add test coverage for integer inputs.

You could consider adding a separate test or parameterizing this one to run with a list of integers, for example [1, 10, 4, 2].

Signed-off-by: yaommen <myanstu@163.com>
@myandpr
Copy link
Member Author

myandpr commented Dec 18, 2025

Hi @goutamvenkat-anyscale , thanks again for yesterday’s review on [Data] Compute Expressions‑Expr Rounding (#59295). This PR is another part of your same issue #58674, and the changes closely follow what we did in the earlier PR. If you have time, could you take a look at this one as well? Thanks a lot!

@ray-gardener ray-gardener bot added data Ray Data-related issues community-contribution Contributed by the community labels Dec 18, 2025
Copy link
Contributor

@goutamvenkat-anyscale goutamvenkat-anyscale left a comment

Choose a reason for hiding this comment

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

lgtm!

@goutamvenkat-anyscale goutamvenkat-anyscale added the go add ONLY when ready to merge, run all tests label Dec 23, 2025
@richardliaw richardliaw enabled auto-merge (squash) December 23, 2025 19:16
@richardliaw richardliaw merged commit 982b6b4 into ray-project:master Dec 23, 2025
8 checks passed
seanlaii pushed a commit to seanlaii/ray that referenced this pull request Dec 23, 2025
Signed-off-by: seanlaii <qazwsx0939059006@gmail.com>
AYou0207 pushed a commit to AYou0207/ray that referenced this pull request Jan 13, 2026
Signed-off-by: jasonwrwang <jasonwrwang@tencent.com>
lee1258561 pushed a commit to pinterest/ray that referenced this pull request Feb 3, 2026
Signed-off-by: lee1258561 <lee1258561@gmail.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
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