Left of |
Anything that produces data: a model name, another pipeline, a previously defined metric, or a value.
products
orders | filter(orders.status == 'delivered')
my_metric
AQLearn 2.2 / Syntax
Source lesson: AQLearn 2.2: Pipe (1). Tangible win: read any AQL pipeline left to right and name the input passed at each |.
Have you ever tried to explain "what does products | count(products.id) actually do" to a teammate or a customer in a presales call?
You hit these pain points:
| does not exist in SQL, so people new to AQL freeze and stop reading.|.count | where | of_all) and lose track of which step receives which input.This lesson solves it: define the one rule that controls every pipe in AQL, draw the data flow visually, and map it to the SQL clauses you already know.
The pipe takes the value on its left and uses it as the input of the function on its right.
left | function(args)
// same as
function(left, args)
That is the entire rule. Everything else in this lesson is just practicing it.
products | count(products.id): products go in, the count function consumes them, a single number comes out.
The pipe is the AQL way to say "this is the data this function operates on". In SQL the same idea is split between the FROM clause and the aggregate function call.
| AQL | SQL |
|---|---|
products | count(products.id) | select count(products.id) from products |
orders | max(orders.created_at) | select max(orders.created_at) from orders |
order_items | sum(order_items.quantity) | select sum(order_items.quantity) from order_items |
In AQL the input model on the left of | is what SQL hides inside the FROM. Putting the input on the left also makes longer pipelines readable: you literally read what happens to the data, left to right.
|Anything that produces data: a model name, another pipeline, a previously defined metric, or a value.
products
orders | filter(orders.status == 'delivered')
my_metric
|A function that knows how to consume that input. Aggregate functions, filter, where, group, select, of_all, and more.
count(products.id)
filter(orders.status == 'delivered')
where(users.gender == 'F')
You can keep piping. Each | hands the previous step's output to the next function.
orders
| filter(orders.status == 'delivered')
| count(orders.id)
where and of_all and filter just become more steps.The pipe operator does not change the dataset shape; it only shapes how a calculation is written. The AQLearn starter for this lesson queries products alongside orders and order_items.
products or orders can sit on the left of a pipe and be the input for an aggregate function on the right.
products with no aggregate, so the value is a row count of the source.products | count(products.id) and re-run.products to orders and read the result aloud as "orders, piped into count of orders.id".Next: Table vs Scalar outputs. The two shapes AQL expressions can return and how the pipe decides which functions are valid.