Show HN: PreQL/Trilogy – A Higher-Level, Composable SQL
An open-source language implemented in Python that replaces the FROM&#x2F;JOINs in SQL with a lightweight semantic layer and compiles to SQL against supported backends.<p>Key features are: Reusability - semantic layer supports full reuse of calculations, CTEs, and even entire models through a lightweight python inspired import syntax.
Simple - writing queries that combines data at different granularity is straightforward and avoids common error patterns.
Easy to refactor - changing the way the semantic layer binds to the database doesn’t require you to rewrite your queries. You don’t need to codemod 100 ETL scripts to deprecate a table!<p>Related packages [basic, links available from <a href="https:&#x2F;&#x2F;preqldata.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;preqldata.dev&#x2F;</a>]:
pypreql-etl -&gt; basic DBT integration. pypreql-nlp -&gt; obligatory GenAI integration. trilogy-studio -&gt; electron IDE for running queries directly. trilogy-public-models -&gt; common repository of public models (mostly BQ public datasets right now) that can be imported&#x2F;queried.<p>Differs from other approaches to make a modern SQL I’m aware of (links below) in that it attempts to embrace current SQL syntax, not replace it. Each of these linked projects has a distinct value proposition and is worth checking out on their own!<p>Note: as you can see by names in the space, it turns out that I was not nearly as creative as I hoped with ‘PreQL’ as a ‘prequel&#x2F;sequel’ play; PreQL&#x2F;Trilogy is the intermediate Star Wars pun and it may migrate to just Trilogy (after the sequel!) to avoid confusion.<p>Other SQL Replacements:<p>Malloy (full rewrite, 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>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>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><p>Things to do:
- Define&#x2F;implement better null handling
- Rewrite some parsing&#x2F;CLI in rust
- More functions&#x2F;backends, more window flexibility
- Performance hooks&#x2F;optimization