Recipe: Add a semantic layer to SQL; use it drop the requirement for joins/group_by; add in type-checking and a lightweight python-esque import syntax to enable reuse and hierarchical querying.
Trilogy is intended to provide an accessible but deep alternative to raw SQL. It offers a new-but-inspired-by-SQL syntax that compiles to various dialects of SQL (with DuckDB as the default).
The target audience is people that really like SQL for analytics and data engineering, but want less boilerplate and sharp edges and looser coupling to the DB.
Semantic models can be easily shared, composed and iterated on in an interactive session, preserving the adhoc workflows that make SQL so powerful.
The "higher level" of the language vis-a-vis SQL makes it straightforward to extend into ETL (an experimental basic DBT integration is available), offering potential to optimize a processing graph across intermediate staging nodes automatically.
This higher level of abstraction also offers some nice opportunities for more reliable text to SQL for LLMs. A similarly basic integration is available to demonstrate this, as is a very basic VsCode extension and electron-based IDE.
Tech stack is primarily Python. Open source, MIT license. Github is linked from demo page. Thoughts, feedback, contributions all welcome!
Note: renamed from PreQL (see prior show https://news.ycombinator.com/item?id=40728938) to avoid confusion with the many PreQLs of the world. The `SQL pun` naming space is unfortunately well-explored.
Other SQL replacements (all great, all worth a look!):
PRQL (pipelined SQL alternative, all new syntax) https://news.ycombinator.com/item?id=36866861
Malloy (all new syntax, semantic focus) https://news.ycombinator.com/item?id=30053860
preql (much more ambitious, all new syntax) https://news.ycombinator.com/item?id=26447070
My litmus test:
I have a table "people" with the columns "people.firstname", "people.lastname", and a table "persons" with the columns "persons.firstname", "persons.lastname". I now want to create a query that gives me the "fullname" (".firstname" + " " + ".lastname") of all rows of both tables. If I have to spell out the logic for how to calculate the fullname in the query twice, the test is failed.
(Taking the shortcut of creating the union of both tables first is not allowed, but I can't think of a simple example that enforces that restriction).
For some reason, all of the solutions (PRQL, Malloy, dbt) that try to make SQL more reusable don't really consider this kind of reuse, and with that ultimately fall flat for the use-cases I would typically have for them. Sadly, Trilogy doesn't seem to be any better on that front.