# Developer builds a query language on Lua to avoid writing a parser

Original title: Lua as a Query Language

> Hacker News story 50683565 · language: en · submitted 2026-11-29
> Web version: https://zeli.app/story/50683565
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 102 · by [remywang](<https://news.ycombinator.com/user?id=remywang>) · 💬 20
[original](<https://remy.wang/blog/lua-ql.html>) · [HN discussion](<https://news.ycombinator.com/item?id=50683565>)

## Summary

Remy Wang, allergic to writing parsers, built Prela as Rust types that mimic a query language — but every query needs rustc compilation, too slow for ad hoc use. So he embedded relational operators in Lua that return AST nodes for a Rust backend. Lua's local variables become CTEs, overloaded operators handle column math, and TPC-H Q18 shrinks to a few readable lines. Security needs sandboxing.

## Key quote

> Somehow I developed an allergy to writing parsers, so severe that I made up an entire query language (called Prela) just to avoid having to parse SQL.

## HN discussion (20 comments)

### [shakna](<https://news.ycombinator.com/item?id=50683887>)

> \> Sadly comparisons like < and == cannot be overloaded in Lua :(
>
> You can overload == in 5.3. Before that, there was a slightly-less-overloadable __eq method. But as of 5.3, as long as the bound __eq method is the same underlying function, it will be called.
>
> I assume you meant instead, that the return value of the comparison is always coerced to a boolean, so you can't re-use it to get arbitrary infix operators?
>
> For that sort of thing, I've used Mike Pall's hack in the past:
>
> local sm = setmetatable
>
> local function infix(f)
>
> local mt = { __sub = function(self, b) return f(self[1], b) end }
>
> return sm({}, { __sub = function(a, _) return sm({ a }, mt) end })
>
> end
>
> local shl = infix(function(a, b) return a*(2^b) end)
>
> print(5 -shl- 4)

### [phillc73](<https://news.ycombinator.com/item?id=50683845>)

> A little while ago I had a similar itch, but my query language at home happened to be Janet[1].
>
> It's built over DuckDB and Rayforce[2]. Single query, either engine.
>
> [1] https://github.com/jennystats/janet-query
>
> [2] https://github.com/RayforceDB/rayforce

### [lasajar](<https://news.ycombinator.com/item?id=50685346>)

> Very nice, Lua is great for creating small DSLs. Honestly I wish Lua was more mainstream as an embedded language.

---

## Cite

- Page: https://zeli.app/story/50683565
- Date: 2026-11-29
- Source: remy.wang (https://remy.wang/blog/lua-ql.html)
- Hacker News: https://news.ycombinator.com/item?id=50683565

## Other languages

- zh: https://zeli.app/zh/story/50683565 · markdown: https://zeli.app/zh/story/50683565.md
- ja: https://zeli.app/ja/story/50683565 · markdown: https://zeli.app/ja/story/50683565.md
- ko: https://zeli.app/ko/story/50683565 · markdown: https://zeli.app/ko/story/50683565.md
- de: https://zeli.app/de/story/50683565 · markdown: https://zeli.app/de/story/50683565.md
- es: https://zeli.app/es/story/50683565 · markdown: https://zeli.app/es/story/50683565.md
- ru: https://zeli.app/ru/story/50683565 · markdown: https://zeli.app/ru/story/50683565.md
