<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=SQL_pipe_syntax</id>
	<title>SQL pipe syntax - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=SQL_pipe_syntax"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=SQL_pipe_syntax&amp;action=history"/>
	<updated>2026-12-06T00:25:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=SQL_pipe_syntax&amp;diff=205&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=SQL_pipe_syntax&amp;diff=205&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:59Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = SQL pipe syntax&lt;br /&gt;
| also_known_as   = Pipe syntax, operator pipe syntax, &amp;lt;code&amp;gt;&amp;amp;#124;&amp;gt;&amp;lt;/code&amp;gt; syntax&lt;br /&gt;
| field           = SQL query languages&lt;br /&gt;
| key_parts       = &amp;lt;code&amp;gt;FROM&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;TABLE&amp;lt;/code&amp;gt; source, pipe operator &amp;lt;code&amp;gt;&amp;amp;#124;&amp;gt;&amp;lt;/code&amp;gt;, operators &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;EXTEND&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SET&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DROP&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AS&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AGGREGATE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;JOIN&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ORDER BY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LIMIT&amp;lt;/code&amp;gt;&lt;br /&gt;
| implementations = [[Apache Spark]], GoogleSQL (BigQuery), ZetaSQL&lt;br /&gt;
| related         = [[Spark SQL scripting]], [[Spark SQL ANSI mode]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/sql-pipe-syntax.md, SqlBaseParser.g4, SQLConf.scala), SPARK-49555, the Spark 4.0.0 and 4.2.0 release notes, the PVLDB 17(12) paper by Shute et al. and the BigQuery pipe syntax reference}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;SQL pipe syntax&amp;#039;&amp;#039;&amp;#039; is an extension of SQL in which a query is written as a sequence of operators joined by the pipe symbol &amp;lt;code&amp;gt;|&amp;gt;&amp;lt;/code&amp;gt;, each operator taking the table produced by the previous one, so that the query reads top to bottom in the order of its logical transformations. [[Apache Spark]] SQL supports pipe syntax since Spark 4.0.0 (SPARK-49555).&amp;lt;ref name=&amp;quot;r400&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-4-0-0.html |title=Spark Release 4.0.0 |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;doc&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/sql-pipe-syntax.html |title=SQL Pipe Syntax (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Pipe syntax keeps standard SQL working unchanged: a query can use standard clauses, pipe operators, or both.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where does SQL pipe syntax come from? ==&lt;br /&gt;
Pipe syntax was described by Jeff Shute and other Google engineers in the paper &amp;quot;SQL Has Problems. We Can Fix Them: Pipe Syntax In SQL&amp;quot;, published in the Proceedings of the VLDB Endowment, volume 17, issue 12 (2024). The paper presents it as an addition to GoogleSQL, Google&amp;#039;s SQL dialect, that fixes the rigid clause order of standard SQL without replacing the language.&amp;lt;ref name=&amp;quot;paper&amp;quot;&amp;gt;{{Cite web |url=https://www.vldb.org/pvldb/vol17/p4051-shute.pdf |title=SQL Has Problems. We Can Fix Them: Pipe Syntax In SQL |publisher=Proceedings of the VLDB Endowment, 17(12): 4051-4063 |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; BigQuery documents pipe syntax as an extension to GoogleSQL, and Google announced that it would be available to all BigQuery users by default from 4 February 2025.&amp;lt;ref name=&amp;quot;bq&amp;quot;&amp;gt;{{Cite web |url=https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/pipe-syntax |title=Pipe syntax (BigQuery documentation) |publisher=Google Cloud |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;bqblog&amp;quot;&amp;gt;{{Cite web |url=https://cloud.google.com/blog/products/data-analytics/simplify-your-sql-with-pipe-syntax-in-bigquery-and-cloud-logging |title=Simplify your SQL with pipe syntax in BigQuery and Cloud Logging |publisher=Google Cloud Blog |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The Spark ticket SPARK-49555 links to the paper and to the open source ZetaSQL implementation.&amp;lt;ref name=&amp;quot;jira&amp;quot;&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-49555 |title=SPARK-49555: SQL Pipe Syntax |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does pipe syntax work in Spark SQL? ==&lt;br /&gt;
A pipe query in Spark SQL usually starts with &amp;lt;code&amp;gt;FROM table_name&amp;lt;/code&amp;gt;, which Spark accepts as a standalone query equivalent to &amp;lt;code&amp;gt;TABLE table_name&amp;lt;/code&amp;gt;. Any number of pipe operators can follow, in any order, each starting with &amp;lt;code&amp;gt;|&amp;gt;&amp;lt;/code&amp;gt; and one or more SQL keywords.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt; Pipe operators can also be appended to the end of any ordinary Spark SQL query.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Spark&amp;#039;s documentation states several invariants. Each operator works the same way on its input regardless of how that input was computed. For a valid chain of N operators, the first M operators (M ≤ N) also form a valid query, which lets a user run a prefix of a query while debugging. Subqueries, views and DDL or DML statements can contain queries in either syntax.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pipe syntax is controlled by &amp;lt;code&amp;gt;spark.sql.operatorPipeSyntaxEnabled&amp;lt;/code&amp;gt;, added in Spark 4.0.0 and &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; by default in Spark 4.3.0.&amp;lt;ref name=&amp;quot;sqlconf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala |title=SQLConf.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Since Spark 4.2.0 a single &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; can also be used as the pipe token (SPARK-51518). This is governed by &amp;lt;code&amp;gt;spark.sql.parser.singleCharacterPipeOperator.enabled&amp;lt;/code&amp;gt;, true by default; the parser tells a pipe apart from bitwise OR by checking whether a pipe operator keyword follows.&amp;lt;ref name=&amp;quot;r420&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-4-2-0.html |title=Spark Release 4.2.0 |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;sqlconf&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;grammar&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4 |title=SqlBaseParser.g4 (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Which pipe operators does Spark SQL support? ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! What it does !! Closest standard Spark SQL&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; || Evaluates expressions over each input row || Outermost &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; of a subquery&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EXTEND&amp;lt;/code&amp;gt; || Appends computed columns || &amp;lt;code&amp;gt;SELECT *, expr AS col&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SET&amp;lt;/code&amp;gt; || Replaces the values of existing columns || &amp;lt;code&amp;gt;SELECT * REPLACE (expr AS col)&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DROP&amp;lt;/code&amp;gt; || Removes columns || &amp;lt;code&amp;gt;SELECT * EXCEPT (col)&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;AS&amp;lt;/code&amp;gt; || Gives the input a new table alias || Table alias&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt; || Filters rows; can appear anywhere, so no separate &amp;lt;code&amp;gt;HAVING&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;QUALIFY&amp;lt;/code&amp;gt; is needed || &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;HAVING&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUALIFY&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;AGGREGATE&amp;lt;/code&amp;gt; || Aggregates, with or without &amp;lt;code&amp;gt;GROUP BY&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;SELECT ... GROUP BY&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;JOIN&amp;lt;/code&amp;gt; || Joins the input (left side) with a table argument (right side) || &amp;lt;code&amp;gt;JOIN&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ORDER BY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LIMIT&amp;lt;/code&amp;gt; || Sorts and limits rows || &amp;lt;code&amp;gt;ORDER BY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LIMIT&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;UNION&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;INTERSECT&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;EXCEPT&amp;lt;/code&amp;gt; || Set operations with another table || Same set operations&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;TABLESAMPLE&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PIVOT&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;UNPIVOT&amp;lt;/code&amp;gt; || Sampling and reshaping || Same clauses&lt;br /&gt;
|}&lt;br /&gt;
Source: Spark 4.3.0 pipe syntax documentation.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;AGGREGATE&amp;lt;/code&amp;gt; differs most from standard SQL. Its output holds the grouping columns first and then the aggregate columns, so the grouping expressions are not repeated in a &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; list. &amp;lt;code&amp;gt;GROUP BY&amp;lt;/code&amp;gt; ordinals refer to the columns of the input table, not to a select list.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt; In Spark 4.3.0 a pipe &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; also accepts aggregate functions and an optional &amp;lt;code&amp;gt;GROUP BY&amp;lt;/code&amp;gt;, as in &amp;lt;code&amp;gt;TABLE t |&amp;gt; SELECT a, SUM(b) AS s GROUP BY a&amp;lt;/code&amp;gt;: the grammar allows a &amp;lt;code&amp;gt;GROUP BY&amp;lt;/code&amp;gt; clause after the select list, the analyzer permits aggregate functions in &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; but rejects them in &amp;lt;code&amp;gt;EXTEND&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SET&amp;lt;/code&amp;gt; and other pipe operators, and the Spark test suite runs such queries.&amp;lt;ref name=&amp;quot;grammar&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;pipeops&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/pipeOperators.scala |title=pipeOperators.scala (tag v4.3.0) |publisher=Apache Spark on GitHub |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;pipetests&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/test/resources/sql-tests/results/pipe-operators.sql.out |title=pipe-operators.sql.out (tag v4.3.0) |publisher=Apache Spark on GitHub |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The Spark 4.2.0 release notes list this change as SPARK-54292.&amp;lt;ref name=&amp;quot;r420&amp;quot; /&amp;gt; The 4.3.0 pipe syntax documentation still says that aggregate functions are not supported in a pipe &amp;lt;code&amp;gt;SELECT&amp;lt;/code&amp;gt; and should go in &amp;lt;code&amp;gt;AGGREGATE&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
The Spark documentation rewrites query 13 of the TPC-H benchmark, which in standard SQL needs a subquery for its two levels of aggregation, as a straight sequence of operators:&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
-- Standard SQL&lt;br /&gt;
SELECT c_count, COUNT(*) AS custdist&lt;br /&gt;
FROM (&lt;br /&gt;
  SELECT c_custkey, COUNT(o_orderkey) c_count&lt;br /&gt;
  FROM customer&lt;br /&gt;
  LEFT OUTER JOIN orders ON c_custkey = o_custkey&lt;br /&gt;
    AND o_comment NOT LIKE &amp;#039;%unusual%packages%&amp;#039;&lt;br /&gt;
  GROUP BY c_custkey&lt;br /&gt;
) AS c_orders&lt;br /&gt;
GROUP BY c_count&lt;br /&gt;
ORDER BY custdist DESC, c_count DESC;&lt;br /&gt;
&lt;br /&gt;
-- The same query with pipe syntax&lt;br /&gt;
FROM customer&lt;br /&gt;
|&amp;gt; LEFT OUTER JOIN orders ON c_custkey = o_custkey&lt;br /&gt;
   AND o_comment NOT LIKE &amp;#039;%unusual%packages%&amp;#039;&lt;br /&gt;
|&amp;gt; AGGREGATE COUNT(o_orderkey) c_count&lt;br /&gt;
   GROUP BY c_custkey&lt;br /&gt;
|&amp;gt; AGGREGATE COUNT(*) AS custdist&lt;br /&gt;
   GROUP BY c_count&lt;br /&gt;
|&amp;gt; ORDER BY custdist DESC, c_count DESC;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A smaller example builds columns step by step and filters on an aggregate without &amp;lt;code&amp;gt;HAVING&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
VALUES (&amp;#039;a&amp;#039;, 10), (&amp;#039;a&amp;#039;, 5), (&amp;#039;b&amp;#039;, 3) AS t(k, v)&lt;br /&gt;
|&amp;gt; EXTEND v * 2 AS v2&lt;br /&gt;
|&amp;gt; AGGREGATE SUM(v2) AS total GROUP BY k&lt;br /&gt;
|&amp;gt; WHERE total &amp;gt; 10&lt;br /&gt;
|&amp;gt; ORDER BY total DESC;&lt;br /&gt;
-- one row: k = &amp;#039;a&amp;#039;, total = 30&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Is pipe syntax more readable? ==&lt;br /&gt;
The paper&amp;#039;s authors argue that standard SQL&amp;#039;s fixed clause order forces subqueries and &amp;quot;inside-out&amp;quot; data flow, and that operators applied in sequence are easier to read, write and extend.&amp;lt;ref name=&amp;quot;paper&amp;quot; /&amp;gt; In Spark SQL, pipe syntax also lets a computed column be used by the next operator without a lateral column alias or a subquery.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt; Pipe syntax is optional: any query can be written in standard Spark SQL, in pipe syntax or in a mix of the two, so it can be adopted one query at a time.&amp;lt;ref name=&amp;quot;doc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Apache Spark]]&lt;br /&gt;
* [[Spark SQL scripting]]&lt;br /&gt;
* [[Spark SQL ANSI mode]]&lt;br /&gt;
* [[Spark Declarative Pipelines]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>