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

SQL: Fix nested ORDER BY #76277

Merged
merged 6 commits into from
Aug 11, 2021
Merged

SQL: Fix nested ORDER BY #76277

merged 6 commits into from
Aug 11, 2021

Conversation

Luegg
Copy link
Contributor

@Luegg Luegg commented Aug 10, 2021

Resolves #76013. Follow up of #75960

As discussed in #75960, the merging of sort orders from multiple OrderBy is now implemented in the query folder.

@Luegg Luegg added :Analytics/SQL SQL querying >bug v7.14.1 v7.15.0 auto-backport Automatically create backport pull requests when merged labels Aug 10, 2021
@Luegg Luegg force-pushed the fix/nestedOrderBy branch from c3baea4 to 9890d36 Compare August 10, 2021 09:06
@Luegg Luegg force-pushed the fix/nestedOrderBy branch from 9890d36 to 0da612e Compare August 10, 2021 09:20
@Luegg Luegg requested review from bpintea, astefan and costin August 10, 2021 09:21
@Luegg Luegg marked this pull request as ready for review August 10, 2021 09:21
@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Aug 10, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Please add a comment to prependSort on why the order is in reverse (due to the iteration of the tree) and it might not be obvious the connection to the other rules.

Comment on lines 707 to 708
for (int i = plan.order().size() - 1; i >= 0; i--) {
Order order = plan.order().get(i);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo, it's cleaner to use the listIterator instead of the index

for (ListIterator<Order> i = plan.order().listIterator(); i.hasPrevious(); ) {
   Order order = i.previous();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I was looking for something to avoid the index lookup but was not aware of ListIterator.

@Luegg
Copy link
Contributor Author

Luegg commented Aug 11, 2021

@elasticmachine run elasticsearch-ci/part-1

@Luegg Luegg merged commit 0fb10cc into elastic:master Aug 11, 2021
@Luegg Luegg deleted the fix/nestedOrderBy branch August 11, 2021 07:42
Luegg pushed a commit to Luegg/elasticsearch that referenced this pull request Aug 11, 2021
* introduce PushDownAndCombineOrderBy optimization

* move merging of order by clauses to QueryFolder

* address review comments

* fix iteration
Luegg pushed a commit to Luegg/elasticsearch that referenced this pull request Aug 11, 2021
* introduce PushDownAndCombineOrderBy optimization

* move merging of order by clauses to QueryFolder

* address review comments

* fix iteration
elasticsearchmachine pushed a commit that referenced this pull request Aug 11, 2021
* introduce PushDownAndCombineOrderBy optimization

* move merging of order by clauses to QueryFolder

* address review comments

* fix iteration
Luegg pushed a commit that referenced this pull request Aug 11, 2021
* introduce PushDownAndCombineOrderBy optimization

* move merging of order by clauses to QueryFolder

* address review comments

* fix iteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/SQL SQL querying auto-backport Automatically create backport pull requests when merged >bug Team:QL (Deprecated) Meta label for query languages team v7.14.1 v7.15.0 v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL: Nested ORDER BY are evaluated in wrong order
5 participants