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

Support distinct projection queries? #1202

Closed
jgeewax opened this issue Oct 22, 2015 · 6 comments
Closed

Support distinct projection queries? #1202

jgeewax opened this issue Oct 22, 2015 · 6 comments
Assignees
Labels
api: datastore Issues related to the Datastore API.

Comments

@jgeewax
Copy link
Contributor

jgeewax commented Oct 22, 2015

Related to #304 (#304 (comment))

and

http://stackoverflow.com/questions/33283759/how-to-do-a-gql-query-using-gcloud-python

How do we do the equivalent of GQL: SELECT DISTINCT p FROM Kind ?

/cc @Fkawala

@jgeewax jgeewax added the api: datastore Issues related to the Datastore API. label Oct 22, 2015
@jgeewax
Copy link
Contributor Author

jgeewax commented Oct 22, 2015

@pcostell : Can the API even allow this type of thing using a structured query object ? Or is this only supported via GQL ?

@tseaver
Copy link
Contributor

tseaver commented Oct 22, 2015

Datastore queries take a projection parameter, which is a list of the fields to be returned. AFAICT, the API don't expose any way to do any "summary" operations (DISTINCT, COUNT, SUM, etc.) except to pull the values back and munge them client-side.

@pcostell
Copy link
Contributor

Sorry OOO so short reply:
Yes it can. In v1beta2 you can use group_by, in v1beta3 you can use distinct_on.

SELECT DISTINCT p FROM Kind == SELECT p FROM KIND GROUP BY p.

Aggregation ops aren't supported because they would require full scans of the data to answer. DISTINCT however can be implemented efficiently.

@Fkawala
Copy link

Fkawala commented Oct 23, 2015

@pcostell so the parameter group_by of object Query does what I expect, and there is not any interest (speed / efficiency ?) to use GQL SELECT DISTINCT ? Thanks.

@pcostell
Copy link
Contributor

@Fkawala -- yes, using group_by on all your projection properties is the exact same as using SELECT DISTINCT IN GQL. (In fact that is how GQL DISTINCT is implemented.

@dhermes
Copy link
Contributor

dhermes commented Dec 31, 2015

@pcostell I'm closing this out. It seems support already exists. LMK if I'm mistaken.

@dhermes dhermes closed this as completed Dec 31, 2015
parthea pushed a commit that referenced this issue Jul 6, 2023
* copy classify_test samples and tests to v1

* flake

* client library version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API.
Projects
None yet
Development

No branches or pull requests

5 participants