-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
SQL: selecting a literal from grouped by query generates error #41413
Comments
Pinging @elastic/es-search |
I was thinking of a solution like this: https://github.com/elastic/elasticsearch/compare/master...codebird:issue%2341413?expand=1 Logic behind it, is that if all we're selecting are literals, then resolved should become all acceptable fields in our field list. Now for some reason, this is considering the group by field as a literal too. so this:
is being considered like this:
So I wanted to get some input on my approach before going forward. |
The status of such queries has been changed. No error is thrown but instead only one row is returned, independently of the buckets that the group by would return, since they are wrongly translated to |
my pull request solves this issue, but for some reason it has been forgotten. |
Hi @codebirg, Apologies for the long delay, but we didn't forget your PR. We wanted to wait for the refactoring merged with: #49570 which simplifies the code in many aspects, so that we could address such issues in a less "hacky" way. |
I'll merge into my branch and check it out @matriv will try to check it out this week |
Thank you @codebird ! |
@codebird |
thank you for looking into it @matriv, this slipped through I had it fixed this time, seems I forgot to move some of the code. I'll fix it today and start working on tests. |
@matriv this issue |
the issue with these 2 queries was fixed. If you can check out my solution. I'll go on with writing the tests. |
Translate to an agg query even if only literals are selected, so that the correct number of rows is returned (number of buckets). Fix issue with key only in GROUP BY (not in select) and WHERE clause: Resolve aggregates and groupings based on the child plan which holds the info info for all the fields of the underlying table. Fixes: #41951 Fixes: #41413 (cherry picked from commit 45b8580)
Translate to an agg query even if only literals are selected, so that the correct number of rows is returned (number of buckets). Fix issue with key only in GROUP BY (not in select) and WHERE clause: Resolve aggregates and groupings based on the child plan which holds the info info for all the fields of the underlying table. Fixes: #41951 Fixes: #41413 (cherry picked from commit 45b8580)
The text was updated successfully, but these errors were encountered: