Discussion Do you guys need a better query language?
Hey guys, there was a number of attempts to make writing queries/reports/data pipelines easier to maintain. There is number of ORMs for different programming languages. And there are also PRQL and btrql.com. Which are new query languages which transpile into SQL.
Kinda like Typescript transpiles into Javascript.
BtrQL is my pet project. Main features of it are: static type checks, Outline showing relation types, extension methods on relations and compile time macro. It's very early and I'm collecting all of the feedback that I can get.
Queries look like this:
users .where(active == TRUE) .addColumn(active -> active_flag) .orderBy(created_at.desc) .limit(10)
and extension methos:
extension [id: INT] { method keepRecentIds = self .where(id >= cutoff) }
keepRecentIds could be applied to any relation that has at least column id of type INT.
9
u/reditandfirgetit Jul 23 '26
SQL is extremely easy to understand. I don't think an additional abstraction over top is necessary. Its just bloat
9
u/Yavuz_Selim Jul 23 '26
Can you show 3 queries that are hard in SQL, but easier (or better) in BetterQL?
(Queries that have some complexicity please; joins, window functions, joins etc.)
4
u/Phil_P Jul 23 '26
One of the problems with ORMs is that you have to learn a custom syntax and then debug and/or performance tune the SQL that it generates. Since it just sends queries to the database server, the DBA has little to no context as to what you’re trying to accomplish. Having a framework that maps stored procedures results into application objects might be a better abstraction.
2
u/joyofresh Jul 23 '26
Consider the history of spark. You can absolutely do this. Most people use sparksql, which compiles from sql to an rdd language more like what youre describing. Sql is not that bad, tho better type safety and structs would be nice. Many model dialects have arrays and structs and json and TVF style exploders. But the interaction layer tends to be sql.
2
u/zbignew Jul 23 '26
'Static' type checking seems like a weird way to put it - all database software is connected to different databases, dynamically. It's inherently not static - you can do your type checking, and connect to the wrong database, and have type failures.
33
u/dab31415 Jul 23 '26 •
No. Completely unnecessary.
14
u/PappyBlueRibs Jul 23 '26
To be honest, I don't think we're the right audience. You'll get a lot of crusty guys here who have used SQL for decades (such as myself) who don't need it AND don't want to learn something unnecessary.
You'd want to test novices, one group learning SQL and one group learning these gosh-darned new versions.
1
u/Content-Parking-621 Jul 25 '26
Honestly the pain isn't SQL syntax for me, it's that errors surface at runtime after a full scan. Static type checks catching a bad column at compile time is the actual win. I am curious how you handle dialect differences, Postgres vs BigQuery diverge fast.