Remy Wang built Prela’s first query interface out of Rust types and methods. That gave it Rust’s editor and compiler tools, but compiling a one-off query could take longer than running it. For ad hoc queries, Wang tried using Lua to build the query and Rust to execute it.

  • Lua variables can name and reuse intermediate expressions without computing them first.
  • Operators like multiplication build a tree of query operations. The Rust engine receives that tree and runs it.
  • An aggregation can call a Lua function once with column expressions. The engine then evaluates the resulting expression over the data without calling Lua for every row.

An embedded language can save you from writing a parser while leaving the engine in control of execution. The trade-off is that users are now submitting scripts. Untrusted scripts would need a sandbox before this prototype could serve them.