Pipe ↔ SQL

Convert BigQuery pipe syntax to standard SQL and back. Runs entirely in your browser. · Docs →

What is BigQuery pipe syntax?

Pipe syntax writes a query as a chain of steps joined by |>, in the order BigQuery runs them. Standard SQL puts SELECT first and FROM after it. Both forms return the same rows and cost the same.

The same query in both forms

Pipe syntax
FROM orders
|> WHERE status = 'completed'
|> AGGREGATE SUM(amount) AS revenue GROUP BY user_id
|> ORDER BY revenue DESC
|> LIMIT 20
Standard SQL
SELECT user_id, SUM(amount) AS revenue
FROM orders
WHERE status = 'completed'
GROUP BY user_id
ORDER BY revenue DESC
LIMIT 20

When to convert

Convert to standard SQL when a tool or a teammate needs the classic form. Convert to pipe syntax when a long query with nested subqueries is hard to read, because each step then sits on its own line.

Read more in BigQuery pipe syntax explained and pipe syntax in Querylab.io.