

Model once. Reuse everywhere. SQL with superpowers.
Approachable
Accurate
Testable
Efficient
Extendable
Composable
Perfect for AI
Familiar Problems?
Informed by the challenges every company has with modern data tooling. Open source so we don't keep having to solve them.
How it actually works
Define concepts and sources
Foundations of your model; iterative and easy to adopt; the same syntax as you query in - and no YAML.
import station as start_station;
import station as end_station;
key ride_id int;
property ride_id.ride_start_time timestamp; # UTC start time
property ride_id.ride_end_time timestamp; # UTC end time
auto ride_seconds <- date_diff(ride_start_time, ride_end_time, second);
auto ride_date <- date_trunc(ride_start_time, day);
datasource rides (
ride_id: ride_id,
start_time: ride_start_time,
end_time: ride_end_time,
start_station: start_station.id,
end_station: end_station.id
)
grain (ride_id)
address rides;
# size our data
select count(ride_id) as ride_count;
Query with the full flexibility of SQL
Fan out joins, foreign keys, and complex logic is resolved automatically through the model.
auto daily_rides <- count(ride_id) by ride_date;
SELECT
day_of_week,
rank start_station.id by avg(daily_rides) desc as daily_station_rank
HAVING
daily_station_rank <5
;
Save data back
Support for the full data lifecycle.
PERSIST daily_ranking INTO tbl_dow_ranking FROM
SELECT
day_of_week,
start_station.id,
daily_station_rank,
;
Reuse
Promote your new definitions up to your core model repos, deploy, and reuse everywhere.
import core_ride_metrics;
WHERE end_station.id in (start_station.id ? daily_station_rank <= 3)
SELECT
ride_id,
start_station.id,
end_station.id,
ride_seconds
ORDER BY
ride_id asc
;
Install
Python SDK
Powerful, expressive python API for embedding the language in larger workflows.
pip install pytrilogy
CLI
A streamlined CLI experience for creating, updating, and sharing Trilogy models.
pip install pytrilogy[cli]
UI
Explore, query, and dashboard your data.
Your favorite editor, Vscode, or Trilogy Studio - which you can clone or run in docker.
The free, hosted version of the Trilogy Studio IDE is a easy way to try out Trilogy.
Hello World
# import from standard library / local files
# for types and fields resuse
import std.display;
# 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,
(len(salutation) / max(len(salutation)) by *)::float::percent as percent_of_longest
;
