Experience Report for Feature Request
I regularly need an
absloute value function in dgraph queries.
Would it be possible to add
abs( <exp> ) ?
What you wanted to do
Compute the absolute value of a number.
What you actually did
math(cond(var<0, -var, var))
var is empty, it crashes with:
Expected a value variable in cond but missing
So I ended up doing:
math(max(var, 0)-min(var, 0))
which doesn’t care if var is empty.
Why that wasn’t great, with examples
Current workaround is too verbose, variables have to be repeated and performances might not be optimal.