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

Problem with distinct and order by #976

Closed
alexpdp7 opened this issue Oct 15, 2019 · 1 comment · Fixed by #978
Closed

Problem with distinct and order by #976

alexpdp7 opened this issue Oct 15, 2019 · 1 comment · Fixed by #978
Assignees
Labels
bug Something isn't working

Comments

@alexpdp7
Copy link

I think there might be a problem with the interaction between ORDER BY and DISTINCT:

MySQL [gitbase]> select distinct repository_id from blobs where blob_hash in ('93ec5b4525363844ddb1981adf1586ebddbc21c1', 'aad34590345310fe813fd1d9eff868afc4cea10c', 'ed82eb69daf806e521840f4320ea80d4fe0af435') order by blob_hash, repository_id;
+-------------------------------------+
| repository_id                       |
+-------------------------------------+
| github.com/src-d/gitbase            |
| github.com/src-d/go-mysql-server    |
| github.com/bblfsh/javascript-driver |
| github.com/bblfsh/python-driver     |
| github.com/bblfsh/ruby-driver       |
| github.com/src-d/enry               |
| github.com/src-d/gitbase            |
| github.com/src-d/go-mysql-server    |
+-------------------------------------+
8 rows in set (0.14 sec)

MySQL [gitbase]> select distinct repository_id from blobs where blob_hash in ('93ec5b4525363844ddb1981adf1586ebddbc21c1', 'aad34590345310fe813fd1d9eff868afc4cea10c', 'ed82eb69daf806e521840f4320ea80d4fe0af435') order by repository_id;
+-------------------------------------+
| repository_id                       |
+-------------------------------------+
| github.com/bblfsh/javascript-driver |
| github.com/bblfsh/python-driver     |
| github.com/bblfsh/ruby-driver       |
| github.com/src-d/enry               |
| github.com/src-d/gitbase            |
| github.com/src-d/go-mysql-server    |
+-------------------------------------+
6 rows in set (0.42 sec)
@erizocosmico erizocosmico added the bug Something isn't working label Oct 15, 2019
@erizocosmico
Copy link
Contributor

For the one who takes this: distinct optimizes the case where all projected columns in the distinct are sorted. But it should only do so if the first column in the order by is present

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

Successfully merging a pull request may close this issue.

2 participants