Putting FROM before SELECT
SQL makes you name columns before you name the table, which breaks autocomplete. I asked for FROM table SELECT columns; it shipped in 22.12.
Source: github.com
SQL asks for the column list before the table, so an editor cannot complete column names while you type them. I was building a SQL editor with autocomplete and kept hitting exactly that wall. I asked for FROM events SELECT *: same semantics, same planner, only the clause order differs.
The thread had one sceptic who preferred a separate query language. Alexey Milovidov disagreed: ClickHouse may be the only DBMS you can give a wide user base raw SQL access to, thanks to RBAC, row-level security, quotas and resource metering, so SQL itself should be made friendlier rather than hidden behind another language. A third participant asked for tests on the awkward cases (subqueries, CTEs, joins, unions).
Contributor evillique implemented it in PR #41095 (“Add ‘FROM table SELECT column’ syntax”), merged 2022-12-02, which closed the issue the same day. It first shipped in 22.12, under three months after I filed it.
Checked on 26.4, the clauses after the select list stay where they were:
FROM events
SELECT event_type, count() AS n
GROUP BY event_type
ORDER BY n DESC;
WHERE goes after the SELECT list, not straight after the table name, and a bare FROM events without SELECT is an error, so this is not a PRQL-style pipe. It composes with subqueries. It is also a small step towards a SQL that reads in the order you think.
Discussion
Comments live in GitHub Discussions. Sign in with GitHub to join in.