DQL operators
Numerical operators
The types long
, double
and timestamp
real represent numerical types. The following operators can be used between pairs of these types
Operator | Description | Example |
---|---|---|
| Addition |
|
| Subtraction |
|
| Multiplication |
|
| Division |
|
| Modulo |
|
| Lower |
|
| Lower than or equal |
|
| Greater |
|
| Greater than or equal |
|
| Equals |
|
| Not equals |
|
ADDITION | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
Long | ||||||||||
Double | ||||||||||
String | ||||||||||
Boolean | ||||||||||
Timestamp | ||||||||||
Duration | ||||||||||
Timeframe | ||||||||||
Binary | ||||||||||
Array | ||||||||||
Record |
SUBTRACT | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
Long | ||||||||||
Double | ||||||||||
String | ||||||||||
Boolean | ||||||||||
Timestamp | ||||||||||
Duration | ||||||||||
Timeframe | ||||||||||
Binary | ||||||||||
Array | ||||||||||
Record |
MULTIPLY | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
Long | ||||||||||
Double | ||||||||||
String | ||||||||||
Boolean | ||||||||||
Timestamp | ||||||||||
Duration | ||||||||||
Timeframe | ||||||||||
Binary | ||||||||||
Array | ||||||||||
Record |
DIVIDE | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
Long | ||||||||||
Double | ||||||||||
String | ||||||||||
Boolean | ||||||||||
Timestamp | ||||||||||
Duration | ||||||||||
Timeframe | ||||||||||
Binary | ||||||||||
Array | ||||||||||
Record |
MODULO | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
Long | ||||||||||
Double | ||||||||||
String | ||||||||||
Boolean | ||||||||||
Timestamp | ||||||||||
Duration | ||||||||||
Timeframe | ||||||||||
Binary | ||||||||||
Array | ||||||||||
Record |
NEGATE | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
SELF |
Logical or equality operators
Operator | Description | Example (yields true) |
---|---|---|
| Equals - Yields true if both operands are not null and equal to each other. Otherwise, false. |
|
| Not equals - Yields null, if one of the operands is null, or if the operands are not equal to each other. |
|
| Negation - Negates a logical state |
|
| Logical and (multiplication) - Yields true if both operands are true. |
|
| Logical or (addition) - Yields true if one of the operands is true, regardless of the other operand. |
|
| Exclusive or - Yields true if one of the operands is true, but false in case both are true. |
|
The behavior of logical operators follows the tri-state boolean logic.
-
AND
true
ANDnull
=null
null
ANDtrue
=null
false
ANDnull
=false
null
ANDfalse
=false
null
ANDnull
=null
-
OR
true
ORnull
=true
null
ORtrue
=true
false
ORnull
=null
null
ORfalse
=null
null
ORnull
=null
-
XOR
true
XORnull
=null
null
XORtrue
=null
false
XORnull
=null
null
XORfalse
=null
null
XORnull
=null
-
NOT
- NOT
null
=null
- NOT
Equality comparisons (==
, !=
) use a tri-state boolean algebra (TRUE, FALSE, NULL). This means that if any side of the equality comparison is NULL, the overall result of the comparison is NULL.
There are two DQL functions that cover scenarios where missing or NULL records need to be retrieved:
For example, the below function that uses basic filtering does not provide null or missing records:
1fetch logs2| filter log.source != "logsourcename" // does not provide the records where `log.source` is null or missing
However, using the isTrueOrNull
function renders those null and missing values:
1fetch logs2| filter isTrueOrNull(log.source != "logsourcename") // also provides the records where `log.source` is null or missing
String operators
By default, all string values in matching expressions are case-sensitive. The caseSensitive
parameter provides the ability to change case sensitivity.
- For details see, string functions.
Operator | Description | Example (yields true) |
---|---|---|
| Equals |
|
| Not equals |
|
| Lower |
|
| Lower than or equal |
|
| Greater |
|
| Greater than or equal |
|
- (
) - false for non-comparable types in case of == operator, true for non-compatible types in case of != operator
- (
) - true/false comparable types based on operator
NULL - if one of the operands is NULL
NULL == NULL - null
==, != | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
Long | ||||||||||
Double | ||||||||||
String | ||||||||||
Boolean | ||||||||||
Timestamp | ||||||||||
Duration | ||||||||||
Timeframe | ||||||||||
Binary | ||||||||||
Array | ||||||||||
Record |
- (
) - true/false based on result of operator
- (
) - null
<, <=, >, >= | Long | Double | String | Boolean | Timestamp | Duration | Timeframe | Binary | Array | Record |
---|---|---|---|---|---|---|---|---|---|---|
Long | ||||||||||
Double | ||||||||||
String | ||||||||||
Boolean | ||||||||||
Timestamp | ||||||||||
Duration | ||||||||||
Timeframe | ||||||||||
Binary | ||||||||||
Array | ||||||||||
Record |
Iterative expressions
Iterative expressions can be used to evaluate every element of a given array or every i-th element of one or more arrays.
iAny
Checks an iterative boolean expression and returns true
, if the expression was true at least once, false
if it wasn't. For example:
1fetch logs2| fieldsAdd a = array(1, 2, 3)3| filter iAny(a[] > 2)
iCollectArray
Collects the results of an iterative expression into an array. For example:
1fetch logs2| fieldsAdd a = array(1, 2, 3), b = array(10, 11, 12)3| fieldsAdd iCollectArray(a[] + b[])
Comparison operators
in
The in
comparison operator evaluates the occurrence of a value returned by the left side's expression within a list of values returned by the right side's DQL subquery.
Syntax
expression in [execution block]
Usage and constraints
Name | Type | Mandatory | Constraints | Description |
---|---|---|---|---|
left side | expression | yes | Either a field identifier or an expression. | The element to be found in the list returned by the right side's subquery. |
right side | execution block | yes | It has to return a single field providing a list of values. | The DQL Subquery which returns the list of values to compare against. |
Example
This example shows how to use the in
keyword for filtering a host metric for the host's attribute:
1timeseries avg(dt.host.cpu.usage), filter:dt.entity.host in [fetch dt.entity.host2 | fieldsAdd tags3 | expand tags4 | filter tags == "ServiceNow" | fields id]