currently i am working on an Uni Project, where we have to measure the response time from different Querys on different graph databases. My group chose Dgraph.
Since i am struggling with a certain query and can’t get it to run without errors, i thought i ask more experienced people in this forum.
The Query is the following:
{
var(func: has(f_relationships)){
f_relationships @facets(d as date){
dateInt as math(since(d))
}
}
data(func: uid(dateVar)){
avgDate : avg(val(dateInt))
}
}
The facet date has the type datetime and the goal is to create a query which computes the average of every date on every edge.
While testing i always come back to the same error.
Repeated id with non int/float value for facet var encountered.
The Documentation of Dgraph on aggregation with facets seems to use integer in their example and since my facet has the type datetime it seems to have problems with it, but i could be interpreting this error completly wrong.
okay but i am using the since function before the average function and if i am understanding the since function correctly its converts the datetime attribute into a new float attribute.
The error disappears after i change the has(f_relationships) into eq(f_id,1), which results in one Node thats returned.
@Wockel Hmm, I don’t see dateVar being set anywhere in your opening block.
There still maybe be an issue with the dateInt being declared at that level. Can you respond with the relevant parts of your schema and a some example predicate values? If so, I’ll try to reproduce and figure out a work-around.
Thanks for that. I looked in the codebase and it seems even tho you’ve math'd the result of since, the query builder still thinks that the variable is not an int or float.
@MichelDiz Do you have any ideas here? I see from an issue in Github you were working with something similar to this a while back. The same issue exists in 21.12.
Can you point me it? This issue feels different. I think only Aman or Harshil would be able to understand the case.
I have my theories. I think as facets don’t have a type, it’s a pure string. This can influence the parser for datetime(just a guess). Perhaps there needed to be a conversion from 2016-08-07 to 2016-08-07T00:00:00Z? And have the type determined in the map.
This use case might be a feature request for facets.
I believe that the easiest way to resolve this is to convert this data into intermediate nodes. Since facet isn’t first class citizen.