BigQuery Pipe Syntax Examples
GoogleSQL pipe syntax uses |> to pass a relation through readable query stages. These examples show how to format pipe chains and keep each transformation visible when a BigQuery query grows.
A basic GoogleSQL pipe chain
A pipe query starts with a table expression or ordinary query, then applies stages in order. The stage names describe the transformation directly, which can make analytical SQL easier to scan than deeply nested subqueries.
FROM `analytics.events`
|> WHERE event_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
|> EXTEND DATE(timestamp) AS event_day
|> ORDER BY event_day DESC;Aggregate and join stages
Use AGGREGATE when the pipe stage changes the relation’s grain, and use JOIN when another source is introduced. The formatter preserves the stage order so a reviewer can follow filtering, grouping, and enrichment as separate decisions.
FROM `analytics.orders` AS o
|> AGGREGATE SUM(amount) AS revenue GROUP BY customer_id
|> JOIN `analytics.customers` AS c USING (customer_id)
|> ORDER BY revenue DESC;Format pipe syntax without flattening it
Choose BigQuery before formatting and enable pipe-stage breaks when a chain is long. The result keeps |> WHERE, |> EXTEND, |> AGGREGATE, and later stages aligned with the relation they receive.
- Keep the source relation easy to identify at the top of the query.
- Break one transformation per stage when the query is under review.
- Use the diff view to verify that formatting changed layout, not stage order.
Continue with the formatter
Ready to format your SQL?
Choose a dialect, format a query, and review the result with a Git-style diff.
Open SQL Formatter