PRQL
Pipelined Relational Query Language, pronounced "Prequel".
PRQL is a modern language for transforming data — a simpler and more powerful SQL. Like SQL, it's readable, explicit and declarative. Unlike SQL, it forms a logical pipeline of transformations, and supports abstractions such as variables and functions. It can be used with any database that uses SQL, since it transpiles to SQL.
PRQL was discussed on Hacker News and Lobsters earlier this year when it was just a proposal.
Here's a short example of the language; for more examples, visit prql-lang.org. To experiment with PRQL in the browser, check out PRQL Playground.
from employees # Each line transforms the previous result.
filter start_date > @2021-01-01 # Clear date syntax.
derive [ # `derive` adds columns / variables.
gross_salary = salary + payroll_tax,
gross_cost = gross_salary + benefits_cost # Variables can use other variables.
]
filter gross_cost > 0
group [title, country] ( # `group` runs a pipeline over each group.
aggregate [ # `aggregate` reduces each group to a row.
average salary,
sum salary,
average gross_salary,
sum gross_salary,
average gross_cost,
sum_gross_cost = sum gross_cost, # `=` sets a column name.
ct = count,
]
)
sort [sum_gross_cost, -country] # `-country` means descending order.
filter ct > 200
take 20
Resources
To learn more, check out the PRQL Website.
For specific resources, check out:
- PRQL Playground — experiment with PRQL in the browser.
- PRQL Book — the language documentation.
- Contributing — join us in building PRQL, through writing code or inspiring others to use it.
- PyPRQL Docs — the PyPRQL documentation, the python bindings to PRQL, including Jupyter magic.
- dbt-prql — write PRQL in dbt models.
- PRQL VSCode Extension
- PRQL-js — JavaScript bindings for PRQL.
Contributors
Many thanks to those who've made our progress possible:
Core developers
We have a few core developers who are responsible for reviewing code, making decisions on the direction of the language, and project administration:
- @aljazerzen — Aljaž Mur Eržen
- @max-sixty — Maximilian Roos
- @charlie-sanders — Charlie Sanders
We welcome others to join who have a track record of contributions.