What is the technical reason we can't store variables of @groupby unless it uses "uid"?

This is not a complaint and more just a question for curiosity sake. I’d like to understand the technical reason why
we can’t store variables on non-uid based @groupby queries?


Groupby was created with this PR Support/groupby by ashwin95r · Pull Request #893 · dgraph-io/dgraph · GitHub - Technically speaking it was created with the use of UIDs in mind. If you need to do something like groupby by attributes. I would recommend using filters.

For example, do you need to find 3 groups? then create a Query with three blocks with their respective filters determining groups. Also, you can create a Var block and use the remaining 3 blocks, to filter the results from Var Block.

This groupby feature does not exist for example in GraphQL nor by ID or attribute. GraphQL clients uses third-party repositories to be able to have groupby by attribute.


I think group by and order by are the most needed for improovment. doing multiple queries for filter has some drawbacks on real life scenarios and can get messy quickly.

Group by, cascade and normalize should work on a per branch level through the query and doing what it is suppose to do at a given branch level, and composing the behavior for its parent grouping / ordering.

I have plans to post a gist with a full case showing how painfull is right now to deal with some common cases in hope that it leads to some care on this subject.

Thanks! Again, it was more a question out of curiousity. I’m aware of ways to work around it but was just wondering it could only be based on UIDs for a technical reason of how the graph works.