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:

TransformPurposeSQL Equivalent
fromStart from a tableFROM
deriveCompute new columnsSELECT *, … AS …
selectPick & compute columnsSELECT … AS …
filterPick rows based on their valuesWHERE, HAVING,QUALIFY
sortOrder rows based on the values of columnsORDER BY
joinAdd columns from another table, matching rows based on a conditionJOIN
takePick rows based on their positionTOP, LIMIT, OFFSET
groupPartition rows into groups and applies a pipeline to each of themGROUP BY, PARTITION BY
aggregateSummarize many rows into one rowSELECT foo(…)
windowApply a pipeline to overlapping segments of rowsOVER, ROWS, RANGE