-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ES|QL: manage INLINE STATS count(*) on result sets with no columns #137017
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
Changes from all commits
b024558
6526e5a
7e4a92d
5345455
b66682d
b2d945e
720bc36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 137017 | ||
| summary: Manage INLINE STATS count(*) on result sets with no columns | ||
| area: ES|QL | ||
| type: bug | ||
| issues: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4362,3 +4362,32 @@ from employees | |
| c:long | ||
| 1 | ||
| ; | ||
|
|
||
|
|
||
| inlineStatsKeepDropCountStar | ||
| required_capability: inline_stats_with_no_columns | ||
|
|
||
| from employees | ||
| | keep emp_no | ||
| | drop emp_no | ||
| | inline stats c = count(*) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fix doesn't seem to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original query had a STATS as last command. I suspect that the problem could still happen with STATS, but I couldn't find a way to reproduce it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I mean, it could have happened, but this fix should also cover normal STATS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to debug the two queries The interesting bit is that with INLINE STATS the page in the aggregator has no blocks, while with STATS it still has the original block for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am looking at this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I've looked at this and your point @luigidellaquila about aggregator having a different behavior for What happens is that with While with regular And there is no ProjectOperator creating an empty Page for which AggregateOperator not to know what to do with it. I am not saying the fix in this PR is not necessary @luigidellaquila (you know better than me the Page with no rows story), but the fact that the code reached a point with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the details and for the in-depth analysis @astefan! |
||
| | limit 3 | ||
| ; | ||
|
|
||
| c:long | ||
| 100 | ||
| 100 | ||
| 100 | ||
| ; | ||
|
|
||
| rowInlineStatsKeepDropCountStar | ||
| required_capability: inline_stats_with_no_columns | ||
|
|
||
| row a = 1 | ||
| | drop a | ||
| | inline stats c = count(*) | ||
| ; | ||
|
|
||
| c:long | ||
| 1 | ||
| ; | ||
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.
Technically this was wrong:
countAlldoes not rely on blocks, it only relies on page.positionCountUh oh!
There was an error while loading. Please reload this page.
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.
Is the intent here to return an illegal value when
countAllis true given thataddRawInputdoes not callblockIndexin that case? E.g. in case a future modification leads to callingpage.getBlock(-1)at line 100 ?Also curious if the intent is to trigger the assert in
addIntermediateInputin that case.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.
Yes, the assert should better protect us now, in case of empty pages.
page.getBlock(-1)will never happen with current implementation, and in case of modifications it will throw a clear error (IMHO better than silently returning a wrong value, because we are calculating results based on the wrong block)