Skip to content
forked from PRQL/prql

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement

License

Notifications You must be signed in to change notification settings

mayhemheroes/prql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRQL

Language Docs Discord Twitter

GitHub CI Status GitHub contributors Stars

Pipelined Relational Query Language, pronounced "Prequel".

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement. 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 compiles to SQL.

PRQL can be as simple as:

from employees
filter country == "USA"                       # Each line transforms the previous result.
aggregate [                                   # `aggregate` reduces column to a value.
  max salary,
  min salary,
  count,                                      # Closing commas are allowed :)
]

Here's a fuller example of the language;

from employees
filter start_date > @2021-01-01               # Clear date syntax.
derive [                                      # `derive` adds columns / variables.
  gross_salary = salary + (tax ?? 0),         # Terse coalesce
  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 gross_salary,
    sum_gross_cost = sum gross_cost,          # `=` sets a column name.
  ]
)
filter sum_gross_cost > 100000                # Identical syntax for SQL's `WHERE` & `HAVING`.
derive id = f"{title}_{country}"              # F-strings like python.
derive country_code = s"LEFT(country, 2)"     # S-strings allow using SQL as an escape hatch
sort [sum_gross_cost, -country]               # `-country` means descending order.
take 1..20                                    # Range expressions (also valid here as `take 20`).

For more on the language, more examples & comparisons with SQL, visit prql-lang.org. To experiment with PRQL in the browser, check out PRQL Playground.

Current status

After several months of building, PRQL is ready to use! Check out the 0.2 Release Notes!

Get involved

To stay in touch with PRQL:

  • Follow us on Twitter
  • Join us on Discord
  • Star this repo
  • Contribute — join us in building PRQL, through writing code or inspiring others to use it. It's easy to get started — the project can be built in a couple of commands, and we're a really friendly community!

Explore

  • PRQL Playground — experiment with PRQL in the browser.
  • PRQL Book — the language documentation.
  • dbt-prql — write PRQL in dbt models.
  • Jupyter magic — run PRQL in Jupyter, either against a DB, or a Pandas DataFrame / CSV / Parquet file through DuckDB.
  • PyPRQL Docs — the PyPRQL documentation, the python bindings to PRQL, including Jupyter magic.
  • PRQL VSCode Extension
  • PRQL-js — JavaScript bindings for PRQL.

Contributors

Many thanks to those who've made our progress possible:

Contributors

Core developers

We have core developers who are responsible for reviewing code, making decisions on the direction of the language, and project administration:

We welcome others to join who have a track record of contributions.

About

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Rust 78.2%
  • CSS 7.3%
  • JavaScript 5.3%
  • HTML 4.8%
  • Java 2.7%
  • Shell 0.9%
  • Other 0.8%