{"by":"efromvt","descendants":40,"id":42231325,"kids":[42237985,42242272,42239983,42236609,42237995,42239635,42236642,42237549],"score":78,"text":"Recipe: Add a semantic layer to SQL; use it drop the requirement for joins&#x2F;group_by; add in type-checking and a lightweight python-esque import syntax to enable reuse and hierarchical querying.<p>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).<p>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.<p>Semantic models can be easily shared, composed and iterated on in an interactive session, preserving the adhoc workflows that make SQL so powerful.<p>The &quot;higher level&quot; 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.<p>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.<p>Tech stack is primarily Python. Open source, MIT license. Github is linked from demo page. Thoughts, feedback, contributions all welcome!<p>Note: renamed from PreQL (see prior show <a href=\"https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40728938\">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40728938</a>) to avoid confusion with the many PreQLs of the world. The `SQL pun` naming space is unfortunately well-explored.<p>Other SQL replacements (all great, all worth a look!):<p>PRQL (pipelined SQL alternative, all new syntax) <a href=\"https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36866861\">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36866861</a><p>Malloy (all new syntax, semantic focus) <a href=\"https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30053860\">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30053860</a><p>preql (much more ambitious, all new syntax) <a href=\"https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26447070\">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26447070</a>","time":1732488783,"title":"Show HN: Trilogy – A Reusable, Composable SQL Experiment","type":"story","url":"https://trilogydata.dev/demo"}