PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

PRQL

PRQL

PRQL, aka Pipelined Relational Query Language, is a query language created in 2022 by Maximilian Roos.

#375on PLDB 0Years Old 4.5kUsers
0Books 0Papers

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


Example from the web:
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 :) ]
Example from the web:
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. sort [sum_gross_cost, -country] # `-country` means descending order. take 1..20 # Range expressions (also valid here as `take 20`).

Language features

Feature Supported Example Token
Comments
# A comment
Line Comments
# A comment
#
Semantic Indentation ϴ
malbolge.html · prql.html · capn-proto.html

View source

PLDB - Build the next great programming language · v2022 · Day 33 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com