Skip to main content

AQL Operators

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

Pipe​

The pipe operator | chains expressions left-to-right by passing the left side as the first positional argument to the function on the right.

expr | fn(args) // equivalent to:
fn(expr, args)

Example:

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

For the conceptual treatment (when pipes shine, the table-vs-scalar mental model, debugging tips), see The pipe operator.

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

List​

OperatorExampleDescription
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 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 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 a relative datetime (relative to the current real world time) like @(last 7 days).

tip

For more information on datetime, please refer to:

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
Include data that equal to an absolute timestamp
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
Include data that are in a time period
!=orders.created_at != @2022-01- orders.created_at is not equal to 2022-01-01 00:00:00Include data that do not equal to an absolute timestamp
is notorders.created_at is not @2022-01- orders.created_at is not in the period of 2022-01Include data that are not in a time period
<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 nullorders.created_at is null- orders.created_at is nullInclude if the value is null
is not nullorders.created_at is not null- orders.created_at is not nullInclude if the value is not null

Open Markdown
Let us know what you think about this document :)