Skip to main content

AQL Operators

A key component of AQL's query syntax involves the utilization of operators to generate more precise metrics.

Logical Operator

These operators serve to compare values and yield a truefalse result.

Text

OperatorExampleDescription
==

is
products.name == 'Dandelion'

products.name is 'Dandelion'
Equal to
!=

is not
products.name != 'Rock'

products.name is not 'Rock'
Not equal to
likeproducts.name like '%Dan'Match the pattern specified
not likeproducts.name not like '%Dan'Not match the pattern specified
ilikeproducts.name ilike '%dan'Match the pattern specified, case insensitive
not ilikeproducts.name not ilike '%dan'Not match the pattern specified, case insensitive
is nullproducts.name is nullInclude if the value is null
is not nullproducts.name is not nullInclude if the value is not null
inproducts.name in ['Dandelion', 'Rock']Include if the value is in the list
not inproducts.name not in ['Dandelion', 'Rock']Include if the value is not in the list

Truefalse

OperatorExampleDescription
isorders.is_paid is trueEqual to
is notorders.is_paid is not trueNot equal to
is nullorders.is_paid is nullInclude if null
is not nullorders.is_paid is not nullInclude if is not null

Number

OperatorExampleDescription
==

is
order_items.discount == 0.5

order_items.discount is 0.5
Equal to
!=

is not
order_items.discount != 1

order_items.discount is not 1
Not equal to
>order_items.discount > 0.5Greater than
<order_items.discount < 0.5Less than
is nullorder_items.discount is nullInclude if null
is not nullorder_items.discount is not nullInclude if is not null

Datetime

Right hand side of datetime operator takes a datetime scalar type as input and always starts with @ token. Datetimes can be expressed in a fully supported format as @YYYY-MM-DD HH:MM:SS, in shorter variations like @YYYY-MM, or relative datetime

OperatorExampleMeaningDescription
== - orders.created_at == @2022
- orders.created_at == @(last 7 days)
- orders.created_at equal to 2022-01-01 00:00:00
- orders_created_at equal to the first timestamp of the last 7 days
Convert the condition input to an absolute timestamp, and include data that match this condition
is
matches
match
- orders.created_at is @2022
- orders.created_at match @(last 7 days)
- orders.created_at is in the period of the year 2022
- order.created_at is in the period of the last 7 days
Convert the condition input to a time period, and include data that match this condition
!=orders.created_at != @2022-01- orders.created_at is not equal to 2022-01-01 00:00:00Convert the condition input to an absolute timestamp, and exclude data that match this condition
<orders.created_at < @2022- orders.created_at is before the year 2022Include data that are before a specific time period
>orders.created_at > @(yesterday)- orders.created_at is after yesterdayInclude data that are after a specific time period
is notorders.created_at is not @2022-01- orders.created_at is not in the period of 2022-01Convert the condition input to a time period, and exclude data that match this condition
is nullorders.created_at is null- orders.created_at is not in the period of 2022-01Include if the value is null
is not nullorders.created_at is not null- orders.created_at is not in the period of 2022-01Include if the value is not null

Pipe Operator

In AQL, we use the pipe | operator to combine multiple expressions into a pipeline in which the output of the previous expression will become the input for the next expression.

Example:

orders | filter(orders.country = 'Singapore') | sum(orders.total_value)

Check AQL Pipe for more information on using pipe


Let us know what you think about this document :)