Skip to content

SQL: ORDER BY a function doesn't actually order nor complains about not being able to #29900

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

Closed
elasticmachine opened this issue Apr 24, 2018 · 1 comment · Fixed by #30585
Closed
Labels

Comments

@elasticmachine
Copy link
Collaborator

Original comment by @astefan:

Example:

POST /_xpack/sql?format=txt
{
  "query": "SELECT author,COUNT(name) FROM library WHERE match(author,'dan') GROUP BY author HAVING COUNT(name)>0 ORDER BY COUNT(name) DESC"
}

Result:

    author     |  COUNT(name)  
---------------+---------------
Dan Andrei     |1              
Dan Bla        |3              
Dan Simmons    |2              

The query being created it's using composite aggregation which doesn't actually allow for "custom" sorting of buckets, only by their values. Accepting an ORDER BY COUNT should, at least, reject the query as not being supported.

@elasticmachine
Copy link
Collaborator Author

Pinging @elastic/es-search-aggs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants