The author developed an allergy to writing parsers so severe they created Prela, a query language designed to avoid parsing SQL. Prela feels like a query language but is actually Rust types and methods, giving immediate access to Rust tooling like type checking, syntax highlighting, and go-to-definition.
The downside is that every query is compiled by rustc, often taking longer than execution itself. That works for repeated queries but adds too much overhead for ad hoc queries. Rather than design a new syntax and parser, the author turned to Lua, an excellent embedded language.
The approach implements relational operators in Lua that return AST nodes instead of executing directly, then passes the AST to the Rust backend. Lua's arithmetic expressions, variables, and local variables handle CTEs as views. Operators like gt, lt, eq, and & are overloaded for relation products and field access.
For aggregations, closures would be too slow due to Lua-Rust roundtrips, so operators are overloaded to work over columns. The result is highly readable queries, including a TPC-H Q18 example that improves on noisy SQL.
Source: Hacker News · Summarized by HeadlinesBriefing