AMQL Docs
AQL ReferenceFunctionsTable functions

select

AQL Syntax: Retrieves one or multiple fields

Definition

Run one expression or multiple expression over each row of a table and use the output to return a new table with the same number of row. In AQL, the select function serves as an intermediate step for subsequent transformations.

Syntax

select(table, expr1, expr2, ...)
select(table, col_name: expr1, ...)
Examples
select(orders, orders.id, orders.status) // -> Table(orders.id, orders.status)

// with pipe
orders | select(orders.id, orders.status) | select(orders.id) // -> Table(orders.id)

// named column
orders | select(orders.status, formatted_status: concat('Status: ', orders.status))

Input

  • table: A model reference or the returned table from a previous expression.
  • expr (repeatable): An expression to evaluate for each row of table.

You need to name the column in the output table (e.g. formatted_status: concat('Status: ', orders.status)). Only expression that has clear fully-qualified column name (e.g. orders.id) can be used directly and reference as-is in the output table.

Output

A table with the same number of rows as the input table, but with only the specified columns. E.g. select(orders, orders.id, formatted_status: concat('Status: ', orders.status) will return a table with 2 columns: orders.id and formatted_status.

orders.statusformatted_status
pendingStatus: pending
cancelledStatus: cancelled
pendingStatus: pending

Sample Usages

List all order items and their value
order_items | select(
  countries.name, 
  products.name,
  value: order_items.quantity * products.price
)
countries->nameproducts->namevalue
VietnamBunk Bed375
VietnamApple Watch 14880
VietnamLucky T-shirt387
VietnamShower curtains238
VietnamTicwatch 11128
VietnamNike Shoes700
VietnamXbox 3601578
VietnamBody Scrub390
VietnamNike Shoes358
VietnamChips 2. Dried Fruit26
VietnamDining Chair 2344
Open in playground ↗
Use select to create an intermediate table for a metric
order_items | select(value: order_items.quantity * products.price) | sum(value)
sum_value
4391797
Open in playground ↗

See also

On this page