Transforms
PRQL queries are a pipeline of transformations (“transforms”), where each transform takes the previous result and adjusts it in some way, before passing it onto to the next transform.
Because PRQL focuses on modularity, we have far fewer transforms than SQL, each one fulfilling a specific purpose. That’s often referred to as “orthogonality”.
These are the currently available transforms:
Transform | Purpose | SQL Equivalent |
---|---|---|
from | Start from a table | FROM |
derive | Compute new columns | SELECT *, … AS … |
select | Pick & compute columns | SELECT … AS … |
filter | Pick rows based on their values | WHERE , HAVING ,QUALIFY |
sort | Order rows based on the values of columns | ORDER BY |
join | Add columns from another table, matching rows based on a condition | JOIN |
take | Pick rows based on their position | TOP , LIMIT , OFFSET |
group | Partition rows into groups and applies a pipeline to each of them | GROUP BY , PARTITION BY |
aggregate | Summarize many rows into one row | SELECT foo(…) |
window | Apply a pipeline to overlapping segments of rows | OVER , ROWS , RANGE |