-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[BugFix] fix json v2 rewrite with lambda #66550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Murphy <mofei@starrocks.com>
🧪 CI InsightsHere's what we observed from your CI run for 3887d72. 🟢 All jobs passed!But CI Insights is watching 👀 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where JSON v2 rewrite incorrectly attempted to rewrite JSON function calls within lambda expressions. The issue occurred when get_json_double was called on a lambda argument (e.g., x in any_match(x -> get_json_double(x, '$.longitude') > 0, ...)). Lambda arguments are ColumnRefOperator instances but are not attached to tables, causing the rewrite rule to fail or produce incorrect expressions.
Key Changes:
- Added early exit check in
JsonPathRewriteRuleto skip rewriting when the JSON column is not attached to a table - Converted defensive null check in
createColumnAccessExpressionto aPreconditions.checkStateassertion - Added test case to verify lambda functions with JSON operations are not incorrectly rewritten
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rule/tree/JsonPathRewriteRule.java | Added check to prevent rewriting JSON functions on lambda arguments; converted null check to precondition assertion |
| fe/fe-core/src/test/java/com/starrocks/sql/plan/JsonPathRewriteTest.java | Added test case [22] verifying lambda functions with JSON operations are not rewritten |
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 5 / 5 (100.00%) file detail
|
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no bugs!
|
@Mergifyio backport branch-4.0 |
✅ Backports have been createdDetails
|
(cherry picked from commit 07cb74c)
Why I'm doing:
What I'm doing:
The lambda function was rewritten into a wrong expresison.
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
Note
Skip rewriting JSON functions when the JSON argument is a lambda variable not attached to a table; add a test for any_match scenario and tighten precondition checks.
ColumnRefOperatornot attached to a table (e.g., lambda variables), by checkingcolumnRefFactory.getTableAndColumn(...).Preconditions.checkStateincreateColumnAccessExpressioninstead of silently returning the original column.get_json_doubleinsideany_matchis not rewritten (JsonPathRewriteTestcase [22]).Written by Cursor Bugbot for commit 3887d72. This will update automatically on new commits. Configure here.