The developer of Prela, a query language implemented in Rust, faced challenges with writing parsers and the compilation overhead of Rust for ad hoc queries. Prela initially relied on Rust types and methods, which provided tooling benefits but resulted in slow compilation times for individual queries.
To enable dynamic queries and bypass the need for a dedicated parser, Prela now integrates Lua as an embedded language. This approach allows relational operators within Lua to generate Abstract Syntax Tree (AST) nodes, which are then passed to the Rust backend for execution. Lua's existing capabilities for arithmetic expressions and variables are utilized to support common query language constructs.
The core idea involves implementing relational operators in Lua that return AST nodes. This method is similar to how dataframe libraries handle relational algebra. Prela's foundation, Tarski's Algebra of Relations, is a pure algebra, which simplifies this integration compared to relational algebra operators that require attribute annotations. Lua's operator overloading and local variables are used to define filters, relation products, and Common Table Expressions (CTEs).
An example query demonstrates how Lua's syntax is used to construct Prela queries. Operators like ":with" and ":select" implement semijoin and relation composition, respectively. Filters such as ":gt", ":lt", and ":eq" are applied, and the "&" operator is overloaded for relation products. Field access, like "customer.mktsegment", is also overloaded to implement selection, and Lua's local variables define views rather than materializing relations immediately.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
The Prela query language now uses Lua as an embedded language to enable dynamic queries and avoid direct parser development. This integration allows relational operators in Lua to return Abstract Syntax Tree (AST) nodes, which are then processed by the Rust backend. The approach leverages Lua's existing features for arithmetic expressions and variables, providing a mechanism for ad hoc queries without the overhead of Rust compilation for each query.