winget install --id=PRQL.prqlc -e
prqlc serves as a CLI for the PRQL compiler.
PRQL Compiler CLI (prqlc)
PRQL Compiler CLI (prqlc) is a command-line tool designed to compile PRQL, a modern language for transforming data, into SQL or other formats. PRQL provides a more intuitive and readable alternative to traditional SQL by enabling users to write pipelined transformations that are both explicit and declarative.
Key Features:
Audience & Benefit:
Ideal for data engineers, analysts, and anyone working with relational databases to streamline query writing and improve code readability. By using PRQL, users can reduce complexity in their data transformation pipelines while maintaining clarity and performance through efficient SQL compilation.
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 tracks
filter artist == "Bob Marley" # Each line transforms the previous result
aggregate { # `aggregate` reduces each column to a value
plays = sum plays,
longest = max length,
shortest = min length, # Trailing commas are allowed
}
Here's a larger 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 value
average gross_salary,
sum_gross_cost = sum gross_cost, # `=` sets a column name
}
)
filter sum_gross_cost > 100_000 # `filter` replaces both of 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.
PRQL is ready to use by the intrepid, either with our supported integrations, or within your own tools, using one of our supported language bindings.
PRQL still has some bugs and some missing features, and is probably only ready to be rolled out to non-technical teams for fairly simple queries.
Development has slowed in the past few months as we decide how to work on a new resolver, which will let us squash many bugs and simplify our code a lot. It'll also let us scale the language without scaling the complexity of the compiler.
While we figure that out, we're also thinking about:
And:
window
transform.We're increasingly open to contributions for bigger rewrites of the resolver given how bottlenecked we are on it. If you're interested in contributing, please reach out in an issue or on Discord.
To stay in touch with PRQL:
This repo is composed of:
It also contains our testing / CI infrastructure and development tools. Check out our development docs for more details.
Many thanks to those who've made our progress possible: