-
Notifications
You must be signed in to change notification settings - Fork 8.3k
SQL with pipes #69364
Description
Recent work by Google [1] argues that SQL is not user-friendly because you can't read it top-down. E.g. processing starts at the "bottom" in the FROM clause or in subqueries (but there are more problems). Alternative languages like KQL and PRQL solved that but nobody adopted them. [1] ]proposes to extend SQL with a pipe operator which makes the syntax a lot more readable, e.g. TPC q13 becomes
FROM customer
|> LEFT OUTER JOIN orders ON c_custkey = o_custkey
AND o_comment NOT LIKE '%unusual%packages%'
|> AGGREGATE COUNT(o_orderkey) c_count
GROUP BY c_custkey
|> AGGREGATE COUNT(*) AS custdist
GROUP BY c_count
|> ORDER BY custdist DESC, c_count DESC;The new syntax is quite light-weight and it can be mapped one-to-one to standard SQL, i.e. only parser changes are needed. They say they deployed pipe SQL to all their internal users (they loved it, an open-source implementation is available at [2]) and will ship it soon to all their public systems. Chances are that other vendors will implement that as well.
All it takes for ClickHouse to support pipe syntax is a brave person who hacks pipe support into our SQL frontend.
[1] SQL Has Problems. We Can Fix Them: Pipe Syntax in SQL
[2] https://github.com/google/zetasql