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

Implement COUNT DISTINCT #869

Closed
gomesfernanda opened this issue Jun 14, 2019 · 5 comments · Fixed by src-d/go-mysql-server#754 or #923
Closed

Implement COUNT DISTINCT #869

gomesfernanda opened this issue Jun 14, 2019 · 5 comments · Fixed by src-d/go-mysql-server#754 or #923
Assignees
Labels
bug Something isn't working

Comments

@gomesfernanda
Copy link

I'm running a query and seems to be having a problem

I'm using source{d} CE and I'm trying to see the unique collaborators for a specific repo.

I'm querying the "commits" table, and my query is:

SELECT COUNT(DISTINCT commit_author_name), repository_id
FROM commits
WHERE repository_id = 'data-intelligence'
GROUP BY repository_id

and I get the number 57.

However, when I run the query:

SELECT DISTINCT commit_author_name, repository_id
FROM commits
WHERE repository_id = 'data-intelligence'

I get the distinct names of
Marcelo Novaes
Fernanda Gomes
Máximo Cuadros

So, the unique number of collaborators is 3 but I get 57 if I do COUNT(DISTINCT commit_author_name).
I don't understand why.

The version of source{d} CE I'm using is v0.14.0-beta.3

@ajnavarro ajnavarro added bug Something isn't working question Further information is requested and removed bug Something isn't working labels Jun 18, 2019
@erizocosmico
Copy link
Contributor

COUNT(DISTINCT x) is not implemented yet, sadly. It's something we know it's missing, but that has not been implemented yet.

You can work around this limitation using the following query:

SELECT COUNT(commit_author_name), repository_id
FROM (
  SELECT DISTINCT commit_author_name, repository_id
  FROM commits
  WHERE repository_id = 'data-intelligence'
) t
GROUP BY repository_id

@erizocosmico erizocosmico changed the title Not being able to count distinct field COUNT DISTINCT is not implemented, but does not show errors when used Jun 18, 2019
@erizocosmico erizocosmico added bug Something isn't working and removed question Further information is requested labels Jun 18, 2019
@erizocosmico
Copy link
Contributor

erizocosmico commented Jun 18, 2019

We should either:

  • Implement count distinct
  • Fail when there is an usage of count distinct, which is not supported

/cc @smola @ajnavarro

@ajnavarro
Copy link
Contributor

we can start with the second choice, throw an error.

@ajnavarro
Copy link
Contributor

ajnavarro commented Jun 19, 2019

Reopened because is not fixed on gitbase.

Right now we are going to return an error, but this issue should be kept to remind a future implementation.

@ajnavarro ajnavarro reopened this Jun 19, 2019
@ajnavarro ajnavarro changed the title COUNT DISTINCT is not implemented, but does not show errors when used Implement COUNT DISTINCT Jun 28, 2019
@erizocosmico erizocosmico added the blocked Some other issue is blocking this label Jul 5, 2019
@erizocosmico
Copy link
Contributor

Waiting on src-d/go-mysql-server#785

@erizocosmico erizocosmico removed the blocked Some other issue is blocking this label Jul 8, 2019
@erizocosmico erizocosmico mentioned this issue Jul 8, 2019
5 tasks
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
3 participants