-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(DQL): @groupby on scalar fields and count duplicate #7746
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @minhaj-shakeel)
query/groupby.go, line 320 at r1 (raw file):
// Currently vars are supported only at the root. // for eg, The following query will result into error:-
Add a detailed comment about why is this behavior not allowed.
query/query0_test.go, line 1480 at r1 (raw file):
c as count(uid) } me(func: uid(c)) {
Add an example of doing a filter based on val(c)
as well. Also check with Anand and see if we are satisfying the requirements of the customers that the request came from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @pawanrawal)
query/groupby.go, line 320 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Add a detailed comment about why is this behavior not allowed.
Done.
query/query0_test.go, line 1480 at r1 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Add an example of doing a filter based on
val(c)
as well. Also check with Anand and see if we are satisfying the requirements of the customers that the request came from.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be creating a doc ticket for this as well.
Reviewed 2 of 2 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @minhaj-shakeel)
query/groupby.go, line 388 at r2 (raw file):
// uid -> count of duplicates. for eg if there are two predicates(u & v) and // the groupby uids for (u1, v1) pair are (uid1, uid2, uid3) then the variable // stores (uid1, 3), (uid2, 3) & (uid2, 2) map.
Maybe a bigger example with something like name and friend would help here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created the ticket.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pawanrawal)
query/groupby.go, line 388 at r2 (raw file):
Previously, pawanrawal (Pawan Rawal) wrote…
Maybe a bigger example with something like name and friend would help here.
Adding it.
can this be put into the next release please? I have a query that doesn't work (using 21.03):
the commented query gives me the following error:
relevant: https://discuss.dgraph.io/t/vars-can-be-assigned-only-when-grouped-by-uid-attribute/16996/2 |
This PR extends support for var inside the @groupby query on a scalar predicate at root.
for example the given query now doesn't result to error:-
Now the uid variable
c
contains map of uid to count of uids with the same age.Suppose for the data :-
The following groupby query:-
returns the result:-
The behaviour will be the same if there are multiple predicates and some of them are uid predicates.
However, it is only supported at root currently. Hence the given query will still return error:-
This change is