BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Google Proposes Adding Pipe Syntax to SQL

Google Proposes Adding Pipe Syntax to SQL

In a recent paper titled "SQL Has Problems. We Can Fix Them", a research team at Google proposed the introduction of a new Pipe Syntax in SQL. Google's solution to address perceived limitations in SQL is currently available in the GoogleSQL and ZetaSQL dialects, but it has received mixed feedback from the community.

To address the design challenges of SQL and make it a more flexible language, the research team at Google is proposing an extension to SQL by introducing piped data flow syntax. This design follows a pattern similar to more recent data languages, such as the MongoDB query language. Jeff Shute, software engineer at Google, and colleagues write:

We don’t need to live with SQL’s flaws. The language is fixable! This paper shows how pipe-structured data flow, inspired by other languages and APIs, can be added to SQL with moderate effort. The resulting language is still SQL, but it’s a better SQL. It’s more flexible, more extensible, and easier to use.

Instead of traditional SQL, where operations are combined into a single statement, piped SQL breaks them into a sequence of steps. For example, the query:

SELECT name, price FROM products WHERE price > 10;

would now be written as:

products | WHERE price > 10 | SELECT name, price;

According to the authors and other experts, adopting Pipe Syntax for SQL could offer several practical benefits, including improved code readability and maintainability, better tooling and IDE support, and enhanced productivity. Since the new syntax is designed to simplify the process of writing, reading, and maintaining SQL queries, it could lead to faster development cycles and more intuitive query structures, making them easier to understand and modify.

Source: Google Research

The Pipe Syntax is currently supported in GoogleSQL, an SQL dialect used across several of Google's SQL products, both publicly and internally, including BigQuery, Spanner, F1, Bigtable, Dremel, and Procella. Shute and colleagues conclude:

Pipe syntax unlocks entirely new ways to work with SQL, opportunities for improved SQL tooling, and future language innovation (...) Replacing SQL isn’t necessary, desirable, or practical. We can fix SQL’s most serious challenges from within the language.

Google is not the only hyperscaler adopting piped SQL; Microsoft has suggested a similar approach in Azure Data Explorer and Fabric KQL DB using the Kusto Query Language (KQL). Richard Hipp, creator of SQLite, is "not overly impressed" and Franck Pachot, database expert and developer advocate at YugabyteDB, argues that it is a "not-so-good idea." Pachot writes:

This pipe syntax is terrible for writing clean SQL code (...) There's a good reason to start a function by its signature, name, input arguments, and returning type in all languages (...) The same is true for an SQL query. The SELECT clause defines what it returns to your program: the columns of the tabular result, with their names (...) Could you look at the query above using pipe syntax? How would you guess the structure of the result from it?

In a popular Reddit thread, user Jabes comments:

I’d say this looks very interesting. Assuming the optimizer is still able to consider the statement as a whole I’d be willing to give it a try if my databases supported it. I wonder if a translation layer is possible.

The new syntax is also available in ZetaSQL, the open-source version of GoogleSQL.

About the Author

Rate this Article

Adoption
Style

BT