Vars can be assigned only when grouped by UID attribute while executing this query
{
var(func: has(evt_uniq_visitor)) @groupby(evt_uniq_visitor){
data as count(uid)
}
res(func:uid(data)){
evt_uniq_visitor
}
}
but I remove res function work very well also I tested the same query in another database it works I don’t know why doesn’t work here and what this error mean
Update. A big problem. This feature depends in the Roaring Bitmaps support. That means it will take longer. Unless we edit the code of the cherry-pick if we choose to not support Roaring Bitmaps.
However, when trying to define a variable, I get the error: “Vars can be assigned only when grouped by UID attribute.”
The query that causes the error:
uid(variable) returns the unique identifier of nodes.
When you write uid(size) which node do you expect to get?
it’s a rhetorical question to explain why it does not make sense:
In fact there are no nodes in the graph representing what you count.
The @groupby(Product.size) can give you an array and each item in the array will have a Product.size value and a count value, but those items are not nodes in the graph and have no uid.
It makes no sense for Dgraph to provide uids of the @groupby result, unless the groupby is done on nodes (which have uids).
That explains the error message you see and why you cannot use variable in that case.
If you need the flexibility of considering your Product.size as nodes then you can design the graph schema so that Product.size is the relation predicate to a ProductSize node with a value.
Doing so you “materialize” sizes values with nodes and you can aggregate along those nodes and obtain a variable (variables in Dgraph are maps uid → values).