Skip to content
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

[BUG] aggregation works incorrectly with LIMIT #1774

Open
Tracked by #1872
Yury-Fridlyand opened this issue Jun 24, 2023 · 3 comments
Open
Tracked by #1872

[BUG] aggregation works incorrectly with LIMIT #1774

Yury-Fridlyand opened this issue Jun 24, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Yury-Fridlyand
Copy link
Collaborator

What is the bug?
LIMIT applied incorrectly in query with aggregation.

How can one reproduce the bug?
Steps to reproduce the behavior:
Run any query with aggregation which returns more than 200 rows. Try adding LIMIT clause.
For example:

select count(*) from online group by all_client / 100 limit 2000

(index online is taken from IT)

Physical plan tree is being executed:
image

What is the expected behavior?
LIMIT rule should be applied correctly for such queries.
Probably pushDownLimit should be rejected if query has aggregation.

What is your host/environment?
main @ 94d5479

Do you have any screenshots?
Customer request: https://opensearch.slack.com/archives/C051JEH8MNU/p1686871225569409

Do you have any additional context?
Related issues: #716, #1764, #1752

@robertbrowncc
Copy link

Is there any indication when the LIMIT issue will be resolved? I am having the same problem as well. Normal queries and such I can go up to any number. However anything with a group by in it is stuck at 200 or lower, the lower values do work.

@robertbrowncc
Copy link

robertbrowncc commented Nov 17, 2023

Found a work around!

If you are experiencing this issue, aggregates/group by is causing and limiting results to only 200 max.

Don't run the query but instead do an explain on your SQL attempt.

The results of the explain will show you the standard opensearch query that would have been based on your SQL.

Screenshot 2023-11-17 at 12 19 28

Get this out and clean it up, then drop back to the normal opensearch query method.

Screenshot 2023-11-17 at 12 51 49

This will then run as intended and return the full set of "buckets" not just 200.

Screenshot 2023-11-17 at 12 54 02

@KingRabbid
Copy link

One solution is to increase the limit for the SQL plugins at cluster level; details here: https://opensearch.org/docs/2.12/search-plugins/sql/settings/, adjust parameter: plugins.query.size_limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants