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