[Data] Fix AliasExpr structural equality to respect rename flag#60711
Conversation
This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename Signed-off-by: slfan1989 <slfan1989@apache.org>
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug in AliasExpr.structurally_equals where the _is_rename flag was compared against itself instead of the other expression's flag. This ensures that structural equality checks for AliasExpr are accurate, which is important for logical optimizations. The change is correct and addresses the issue effectively.
To prevent future regressions, I recommend adding a unit test to cover this specific case. A test comparing an AliasExpr created with alias() (_is_rename=False) and one created with _rename() (_is_rename=True) would have caught this bug and will help safeguard the fix.
|
Thanks. Can you please add a unit test? |
Thanks for your message — I’ll add unit tests. |
This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename Signed-off-by: slfan1989 <slfan1989@apache.org>
|
@goutamvenkat-anyscale @bveeramani I've added the new unit test. Could you please take another look at the PR when you have a moment? Thank you so much! |
| from ray.data.expressions import col | ||
|
|
||
|
|
||
| def test_alias_structurally_equals_respects_rename_flag(): |
There was a problem hiding this comment.
You can actually move this into python/ray/data/tests/unit/expressions/test_core.py . There's already a class for AliasExpr
There was a problem hiding this comment.
Thanks for reviewing the code — I’ve made the changes based on your suggestions.
This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename Signed-off-by: slfan1989 <slfan1989@apache.org>
|
@goutamvenkat-anyscale Thanks so much for reviewing the code! |
|
@goutamvenkat-anyscale @alexeykudinkin Thanks a lot for helping review the code! |
…project#60711) ## Description This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename ## Related issues > Link related issues: "Fixes ray-project#1234", "Closes ray-project#1234", or "Related to ray-project#1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. <!-- BUGBOT_STATUS --><sup><a href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> is reviewing your changes for commit <u>9a399ac</u></sup><!-- /BUGBOT_STATUS --> --------- Signed-off-by: slfan1989 <slfan1989@apache.org> Co-authored-by: Goutam <goutam@anyscale.com> Signed-off-by: tiennguyentony <46289799+tiennguyentony@users.noreply.github.com>
…project#60711) ## Description This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename ## Related issues > Link related issues: "Fixes ray-project#1234", "Closes ray-project#1234", or "Related to ray-project#1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. <!-- BUGBOT_STATUS --><sup><a href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> is reviewing your changes for commit <u>9a399ac</u></sup><!-- /BUGBOT_STATUS --> --------- Signed-off-by: slfan1989 <slfan1989@apache.org> Co-authored-by: Goutam <goutam@anyscale.com>
## Description This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename ## Related issues > Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. <!-- BUGBOT_STATUS --><sup><a href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> is reviewing your changes for commit <u>9a399ac</u></sup><!-- /BUGBOT_STATUS --> --------- Signed-off-by: slfan1989 <slfan1989@apache.org> Co-authored-by: Goutam <goutam@anyscale.com> Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
## Description This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename ## Related issues > Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. <!-- BUGBOT_STATUS --><sup><a href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> is reviewing your changes for commit <u>9a399ac</u></sup><!-- /BUGBOT_STATUS --> --------- Signed-off-by: slfan1989 <slfan1989@apache.org> Co-authored-by: Goutam <goutam@anyscale.com>
…project#60711) ## Description This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename ## Related issues > Link related issues: "Fixes ray-project#1234", "Closes ray-project#1234", or "Related to ray-project#1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. <!-- BUGBOT_STATUS --><sup><a href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> is reviewing your changes for commit <u>9a399ac</u></sup><!-- /BUGBOT_STATUS --> --------- Signed-off-by: slfan1989 <slfan1989@apache.org> Co-authored-by: Goutam <goutam@anyscale.com> Signed-off-by: Adel Nour <ans9868@nyu.edu>
…project#60711) ## Description This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown). Main changes: Correct comparison of _is_rename against other._is_rename ## Related issues > Link related issues: "Fixes ray-project#1234", "Closes ray-project#1234", or "Related to ray-project#1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. <!-- BUGBOT_STATUS --><sup><a href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> is reviewing your changes for commit <u>9a399ac</u></sup><!-- /BUGBOT_STATUS --> --------- Signed-off-by: slfan1989 <slfan1989@apache.org> Co-authored-by: Goutam <goutam@anyscale.com>
Description
This PR fixes a bug in AliasExpr.structurally_equals where the rename marker was always treated as equal, causing incorrect structural equality results. This could affect logical optimization rules that rely on accurate expression equivalence (e.g., projection pushdown).
Main changes:
Correct comparison of _is_rename against other._is_rename
Related issues
Additional information
Cursor Bugbot is reviewing your changes for commit 9a399ac