Skip to content
← Open source

WrenAI

Two merged fixes to an open source text to SQL engine: typed cube ordering in the WebAssembly SDK and safer subquery wrapping across database connectors.

Role
Contributor
When
September 2026
Stack
TypeScript, Python, Rust, WebAssembly

Context

WrenAI turns natural language questions into SQL through a semantic layer that describes models, metrics and relationships. Its query engine, wren-core, is written in Rust on top of Apache DataFusion and is also compiled to WebAssembly so it can run in the browser, with a TypeScript SDK on top. Connectors in Python then send the generated SQL to databases such as PostgreSQL, ClickHouse or Databricks.

What I contributed

Typed orderBy for cube queries (#2753). The Rust engine had recently gained native support for ordering cube query results. Because the WebAssembly runtime passes the JSON query straight to the deserializer, ordering already worked at runtime, but the TypeScript SDK had no type for it. TypeScript users had to cast their queries to get past the compiler. I added the orderBy types to the SDK, together with SDK tests.

Trailing comments in wrapped SQL (#2754). To preview or dry run a query, the connectors wrap the user's SQL in a subquery on a single line: SELECT * FROM (<sql>) AS t LIMIT n. If the user's SQL ended with a -- comment, the comment swallowed the closing parenthesis, the alias and the LIMIT, and the query failed. The maintainers had already fixed this for several connectors. I finished the remaining ones (Canner, ClickHouse, Databricks and DataFusion) by putting the inner SQL on its own lines, and added regression tests for each connector.

Why it matters

Both changes are small, but they sit on paths every user goes through: typing a query in the SDK and previewing a result. The second one is a good example of a bug that is easy to fix once and easy to forget elsewhere, which is why I covered every remaining connector in one pull request with a test for each.

Pull requests

2 merged, 0 open, 0 closed. Status synced from GitHub.

← All projects