-
Notifications
You must be signed in to change notification settings - Fork 25.3k
ESQL: Align RENAME
behavior with EVAL
for sequential processing
#122250
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
During code validation, a question arose:
When the pre-modification name and the post-modification name are the same, should it throw a I think #122165 is a related issue to this problem. |
Pinging @elastic/es-analytical-engine (Team:Analytics) |
RENAME
logic to swap namesRENAME
logic to swap names
@kanoshiou thank you for this contribution. At this point, though, this subject is in internal discussions on how ES|QL should actually behave in this case. There are other similar scenarios in other queries involving overrides and all of these should be considered when making a decision. |
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.
Hi @kanoshiou, sorry for the delay!
After some discussions, we want to keep RENAME as similar as other commands like EVAL as possible, where operations are "executed" from left to right.
For RENAME, it means that:
| RENAME a AS b, b AS c
Should be identical to:
| RENAME a AS b
| RENAME b AS c
And that:
ROW a=1, b=2
| RENAME
a AS b, // b=1 ("a" got renamed to "b", "b" is no longer accessible)
b AS a // a=1 (the new "b" got renamed to "a" again)
Should first shadow the original b
, and finally leave only a
.
I've added some comments with what would be the expected result of the CSV tests, and some proposed new tests to cover some potential edge cases.
Also, about the case you comment: row foo = 10, bar = null | rename bar2 as bar2
I would leave it out of this PR. I see you commented on the other issue already; that should be enough for when we want to open a discussion over that topic.
Thank you again! I'll be watching this PR for when a review is needed; tell me if there's something you need
x-pack/plugin/esql/qa/testFixtures/src/main/resources/rename.csv-spec
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/qa/testFixtures/src/main/resources/rename.csv-spec
Outdated
Show resolved
Hide resolved
Thank you @ivancea for your review and for assisting with the test cases. I've updated the branch, and it would be great if you could review it at your convenience. |
RENAME
logic to swap namesRENAME
behavior with EVAL
for sequential processing
buildkite test this |
buildkite test this |
buildkite test this |
(Sorry for the repeated commands and merges; there's a failing check and I'm trying to ensure that it's unrelated before merging) |
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.
Thank you!
…122250) (#125325) Co-authored-by: kanoshiou <[email protected]>
…sing (#122250) (#125324) * ESQL: Align `RENAME` behavior with `EVAL` for sequential processing (#122250) * Fixed line length on comment for 8.x --------- Co-authored-by: kanoshiou <[email protected]>
We shouldn't mutate LogicalPlan.child().output() (or just LogicalPlan.output()); we did so in RENAME, but only in EsqlNodeSubclassTest, making them flaky. >The PR at #122250 seems to have created a flaky test failure in `EsqlNodeSubclassTests`. Local runs with `-Dtests.iters=100` lead to about two dozen failures in over 70k tests run. This is not a high failure rate, but still requires addressing. > >The single line added to the Analyzer by that PR causes an `UnsupportedOperationException` on attempting to mutate an immutable collection when running `EsqlNodeSubclassTests`. It turns out that this code path comes from `Rename.output()` which is only called in test scenarios. So a quick fix is to copy the child output into a mutable collection.
We shouldn't mutate LogicalPlan.child().output() (or just LogicalPlan.output()); we did so in RENAME, but only in EsqlNodeSubclassTest, making them flaky. >The PR at elastic#122250 seems to have created a flaky test failure in `EsqlNodeSubclassTests`. Local runs with `-Dtests.iters=100` lead to about two dozen failures in over 70k tests run. This is not a high failure rate, but still requires addressing. > >The single line added to the Analyzer by that PR causes an `UnsupportedOperationException` on attempting to mutate an immutable collection when running `EsqlNodeSubclassTests`. It turns out that this code path comes from `Rename.output()` which is only called in test scenarios. So a quick fix is to copy the child output into a mutable collection.
We shouldn't mutate LogicalPlan.child().output() (or just LogicalPlan.output()); we did so in RENAME, but only in EsqlNodeSubclassTest, making them flaky. >The PR at elastic#122250 seems to have created a flaky test failure in `EsqlNodeSubclassTests`. Local runs with `-Dtests.iters=100` lead to about two dozen failures in over 70k tests run. This is not a high failure rate, but still requires addressing. > >The single line added to the Analyzer by that PR causes an `UnsupportedOperationException` on attempting to mutate an immutable collection when running `EsqlNodeSubclassTests`. It turns out that this code path comes from `Rename.output()` which is only called in test scenarios. So a quick fix is to copy the child output into a mutable collection.
We shouldn't mutate LogicalPlan.child().output() (or just LogicalPlan.output()); we did so in RENAME, but only in EsqlNodeSubclassTest, making them flaky. >The PR at #122250 seems to have created a flaky test failure in `EsqlNodeSubclassTests`. Local runs with `-Dtests.iters=100` lead to about two dozen failures in over 70k tests run. This is not a high failure rate, but still requires addressing. > >The single line added to the Analyzer by that PR causes an `UnsupportedOperationException` on attempting to mutate an immutable collection when running `EsqlNodeSubclassTests`. It turns out that this code path comes from `Rename.output()` which is only called in test scenarios. So a quick fix is to copy the child output into a mutable collection.
We shouldn't mutate LogicalPlan.child().output() (or just LogicalPlan.output()); we did so in RENAME, but only in EsqlNodeSubclassTest, making them flaky. >The PR at #122250 seems to have created a flaky test failure in `EsqlNodeSubclassTests`. Local runs with `-Dtests.iters=100` lead to about two dozen failures in over 70k tests run. This is not a high failure rate, but still requires addressing. > >The single line added to the Analyzer by that PR causes an `UnsupportedOperationException` on attempting to mutate an immutable collection when running `EsqlNodeSubclassTests`. It turns out that this code path comes from `Rename.output()` which is only called in test scenarios. So a quick fix is to copy the child output into a mutable collection.
We shouldn't mutate LogicalPlan.child().output() (or just LogicalPlan.output()); we did so in RENAME, but only in EsqlNodeSubclassTest, making them flaky. >The PR at elastic#122250 seems to have created a flaky test failure in `EsqlNodeSubclassTests`. Local runs with `-Dtests.iters=100` lead to about two dozen failures in over 70k tests run. This is not a high failure rate, but still requires addressing. > >The single line added to the Analyzer by that PR causes an `UnsupportedOperationException` on attempting to mutate an immutable collection when running `EsqlNodeSubclassTests`. It turns out that this code path comes from `Rename.output()` which is only called in test scenarios. So a quick fix is to copy the child output into a mutable collection.
The
RENAME
command should function as similarly to other commands likeEVAL
as possible, executing operations sequentially from left to right.For example, the following query:
is equivalent to:
and should produce the result:
Closes #121739