

Trilogy: Composable, reusable analytics — in a SQL-inspired language that’s testable, type-safe, and built for teams. Model once. Run anywhere.
Familiar
Looks like SQL. Feels like code.
Accurate
No gotchas with grouping or joins.
Testable
Type-safe analytics with modular, testable logic.
Efficient
Write less. Stage less. Run what matters.
Extendable
Open source. Rich python API.
Composable
Models as building blocks: share, reuse, and compose with ease.
LLM-Native
Designed to be human-readable and LLM-friendly.
Install
pip install pytrilogy
Trilogy is a data modeling language with first-class support for logic, functions, and reuse. Here's a hello world:
Hello, World
# model logic is written first
# with a pure semantic model
const greeting <- 'Hello'; # comments describe fields
key noun string; # people, places, things
# that you bind to data
datasource things (
thing:noun
)
grain (noun)
query '''
select unnest(['world', 'friend', 'visitor']) as thing
''';
# with reusable functions
def initcap(word)-> upper(substring(word, 1, 1)) || substring(word,2, len(word));
# and run queries in familiar SQL syntax
WHERE noun like '%world%' or noun = 'friend'
SELECT
greeting || ' ' || @initcap(noun) || '!' as salutation,
rank salutation by len(salutation) asc as brevity_rank
;