Dgraph DQL Tour
Var Blocks
Value variables: math functions
As well as min
, max
, avg
, and sum
to aggregate, Dgraph supports a host
of functions that can be applied to value variables. These need to be enclosed
in math(...)
and stored in a variable.
The full list is:
Operator | Accepted Type | Notes |
---|---|---|
+ - * / % |
int and float |
|
min max |
All types except geo and bool |
|
< > <= >= == != |
All, except geo and bool |
boolean result |
floor ceil ln exp sqrt |
int and float |
|
since |
date |
number of seconds (float ) from the time specified |
pow(a, b) |
int and float |
a^b |
logbase(a,b) |
int and float |
log(a) to the base b |
cond(a, b, c) |
a must be a boolean |
selects b if a is true else c |
Note that these are functions on values, not functions to aggregate value maps. The results of these functions are value variables and can be aggregated.