Numeric functions
Clojure users: note that XTDB functions will return null if any argument is null, as per the SQL spec.
Basic arithmetic functions
The standard arithmetic functions are available:
Datalog | SQL | |
---|---|---|
|
|
addition |
|
|
subtraction |
|
|
multiplication |
|
|
division |
-
If any input expression is null, the result will also be null.
-
If all arguments are integers, the result will also be an integer; otherwise, all arguments will be cast to floating-point values before applying the function. Particularly, the division function performs integer division if it’s only given integer values.
-
If the result would under-/overflow the widest type of the input arguments, a runtime exception will be thrown.
-
Trying to divide by zero will result in a runtime exception.
-
Where the XTQL variants are variadic (e.g.
(+ exprs …)
), they can accept any amount of arguments.e.g. `(+ a b c d)` is equivalent to `a + b + c + d`
Other numeric functions
Datalog | SQL | |
---|---|---|
|
|
absolute value of |
|
|
nearest integer greater than or equal to |
|
|
|
|
|
'e' (base of natural logarithms) raised to the `x`th power |
|
|
nearest integer less than or equal to |
|
|
natural logarithm |
|
logarithm of |
|
|
logarithm of |
|
|
|
modulus of |
|
|
|
|
|
square root |
-
If any input expression is null, the result will also be null.
-
If the result would under-/overflow the widest type of the input arguments, a runtime exception will be thrown.
-
Trying to divide by zero will result in a runtime exception.
Trigonometric functions
Datalog | SQL | |
---|---|---|
|
|
inverse cosine |
|
|
inverse sine |
|
|
inverse tangent |
|
|
cosine |
|
|
hyperbolic cosine |
|
|
sine |
|
|
hyperbolic sine |
|
|
tangent |
|
|
hyperbolic tangent |
-
Arguments and results in radians
Prev
PredicatesNext
String functions