Pipe Syntax Formatting
Pipe syntax (|>) is supported in BigQuery, Spark, and Databricks. Each pipe step starts on a new line with |> leading.
Behavior: The |> operator leads each pipe step on a new line. The pipe operation content (SELECT, WHERE, etc.) follows on the same line when it fits, or is indented below when it exceeds maxLineWidth.
Internal formatting: Pipe operations follow the same formatting rules as their non-pipe equivalents:
|> SELECTitems follow SELECT item style|> WHEREconditions get AND/OR line-breaking|> ORDER BYitems follow ORDER BY item style
Subqueries: Pipe steps inside subqueries are indented along with the subquery.
Simple pipe query
select 1 as x, 2 as y |> select *, x + y as z |> select x, z
select 1 as x, 2 as y |> select *, x + y as z |> select x, z
Pipe with WHERE
from orders |> where status = 'active' |> select customer_id, total
from orders |> where status = 'active' |> select customer_id, total
Pipe with ORDER BY and LIMIT
from orders |> where total > 100 |> order by total desc |> limit 10
from orders |> where total > 100 |> order by total desc |> limit 10
Pipe with aggregate
from orders |> aggregate count(*) as cnt, sum(total) as total_sum group by customer_id
from orders
|> aggregate count(*) as cnt, sum(total) as total_sum group by customer_id
Single pipe step
select a, b from t |> where a > 1
select a, b from t |> where a > 1
Pipe SELECT with many items (BODY style)
from orders |> select customer_id, order_date, total, status, region
from orders |> select customer_id, order_date, total, status, region
Pipe SELECT with STACKED style
from orders |> select customer_id, total, status
from orders |> select customer_id, total, status
Pipe WHERE with AND/OR
from orders |> where status = 'active' and total > 100 and region = 'US'
from orders |> where status = 'active' and total > 100 and region = 'US'
Pipe ORDER BY with multiple items (BODY style)
from orders |> order by region asc, total desc, customer_id asc
from orders |> order by region asc, total desc, customer_id asc
Pipe in CTE subquery
WITH active AS (FROM orders |> WHERE status = 'active' |> SELECT customer_id, total) SELECT * FROM active
with
active as (
from orders
|> where status = 'active'
|> select customer_id, total
)
select *
from active