Skip to content

plprql

Use PRQL in PostgreSQL - Pipelined Relational Query Language

plprql · Use PRQL in PostgreSQL - Pipelined Relational Query Language

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3040plprqlplprql18.0.2LANGApache-2.0Rust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--NoYesNoYesnono

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY18.0.219 18 17 16 15plprql-
RPMPIGSTY18.0.219 18 17 16 15plprql_$v-
DEBPIGSTY18.0.219 18 17 16 15postgresql-$v-plprql-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
el8.aarch64N/APIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
el9.x86_64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
el9.aarch64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
el10.x86_64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
el10.aarch64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
d12.x86_64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
d12.aarch64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
d13.x86_64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
d13.aarch64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
u22.x86_64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
u22.aarch64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
u24.x86_64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
u24.aarch64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
u26.x86_64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
u26.aarch64PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2PIGSTY 18.0.2
PackageVersionOSORGSIZEFile URL
plprql_1818.0.2el8.x86_64pigsty4.0 MiBplprql_18-18.0.2-1PGSTY.el8.x86_64.rpm
plprql_1818.0.2el8.aarch64pigsty3.5 MiBplprql_18-18.0.2-1PGSTY.el8.aarch64.rpm
plprql_1818.0.2el9.x86_64pigsty4.8 MiBplprql_18-18.0.2-2PGSTY.el9.x86_64.rpm
plprql_1818.0.2el9.aarch64pigsty4.5 MiBplprql_18-18.0.2-2PGSTY.el9.aarch64.rpm
plprql_1818.0.2el10.x86_64pigsty4.8 MiBplprql_18-18.0.2-2PGSTY.el10.x86_64.rpm
plprql_1818.0.2el10.aarch64pigsty4.5 MiBplprql_18-18.0.2-2PGSTY.el10.aarch64.rpm
postgresql-18-plprql18.0.2d12.x86_64pigsty3.1 MiBpostgresql-18-plprql_18.0.2-2PGSTY~bookworm_amd64.deb
postgresql-18-plprql18.0.2d12.aarch64pigsty2.7 MiBpostgresql-18-plprql_18.0.2-2PGSTY~bookworm_arm64.deb
postgresql-18-plprql18.0.2d13.x86_64pigsty3.1 MiBpostgresql-18-plprql_18.0.2-2PGSTY~trixie_amd64.deb
postgresql-18-plprql18.0.2d13.aarch64pigsty2.7 MiBpostgresql-18-plprql_18.0.2-2PGSTY~trixie_arm64.deb
postgresql-18-plprql18.0.2u22.x86_64pigsty3.5 MiBpostgresql-18-plprql_18.0.2-2PGSTY~jammy_amd64.deb
postgresql-18-plprql18.0.2u22.aarch64pigsty3.3 MiBpostgresql-18-plprql_18.0.2-2PGSTY~jammy_arm64.deb
postgresql-18-plprql18.0.2u24.x86_64pigsty3.5 MiBpostgresql-18-plprql_18.0.2-2PGSTY~noble_amd64.deb
postgresql-18-plprql18.0.2u24.aarch64pigsty3.3 MiBpostgresql-18-plprql_18.0.2-2PGSTY~noble_arm64.deb
postgresql-18-plprql18.0.2u26.x86_64pigsty3.4 MiBpostgresql-18-plprql_18.0.2-2PGSTY~resolute_amd64.deb
postgresql-18-plprql18.0.2u26.aarch64pigsty3.3 MiBpostgresql-18-plprql_18.0.2-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
plprql_1718.0.2el8.x86_64pigsty4.0 MiBplprql_17-18.0.2-1PGSTY.el8.x86_64.rpm
plprql_1718.0.2el8.aarch64pigsty3.5 MiBplprql_17-18.0.2-1PGSTY.el8.aarch64.rpm
plprql_1718.0.2el9.x86_64pigsty4.8 MiBplprql_17-18.0.2-2PGSTY.el9.x86_64.rpm
plprql_1718.0.2el9.aarch64pigsty4.5 MiBplprql_17-18.0.2-2PGSTY.el9.aarch64.rpm
plprql_1718.0.2el10.x86_64pigsty4.8 MiBplprql_17-18.0.2-2PGSTY.el10.x86_64.rpm
plprql_1718.0.2el10.aarch64pigsty4.5 MiBplprql_17-18.0.2-2PGSTY.el10.aarch64.rpm
postgresql-17-plprql18.0.2d12.x86_64pigsty3.1 MiBpostgresql-17-plprql_18.0.2-2PGSTY~bookworm_amd64.deb
postgresql-17-plprql18.0.2d12.aarch64pigsty2.7 MiBpostgresql-17-plprql_18.0.2-2PGSTY~bookworm_arm64.deb
postgresql-17-plprql18.0.2d13.x86_64pigsty3.1 MiBpostgresql-17-plprql_18.0.2-2PGSTY~trixie_amd64.deb
postgresql-17-plprql18.0.2d13.aarch64pigsty2.7 MiBpostgresql-17-plprql_18.0.2-2PGSTY~trixie_arm64.deb
postgresql-17-plprql18.0.2u22.x86_64pigsty3.5 MiBpostgresql-17-plprql_18.0.2-2PGSTY~jammy_amd64.deb
postgresql-17-plprql18.0.2u22.aarch64pigsty3.3 MiBpostgresql-17-plprql_18.0.2-2PGSTY~jammy_arm64.deb
postgresql-17-plprql18.0.2u24.x86_64pigsty3.5 MiBpostgresql-17-plprql_18.0.2-2PGSTY~noble_amd64.deb
postgresql-17-plprql18.0.2u24.aarch64pigsty3.3 MiBpostgresql-17-plprql_18.0.2-2PGSTY~noble_arm64.deb
postgresql-17-plprql18.0.2u26.x86_64pigsty3.4 MiBpostgresql-17-plprql_18.0.2-2PGSTY~resolute_amd64.deb
postgresql-17-plprql18.0.2u26.aarch64pigsty3.2 MiBpostgresql-17-plprql_18.0.2-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
plprql_1618.0.2el8.x86_64pigsty4.0 MiBplprql_16-18.0.2-1PGSTY.el8.x86_64.rpm
plprql_1618.0.2el8.aarch64pigsty3.5 MiBplprql_16-18.0.2-1PGSTY.el8.aarch64.rpm
plprql_1618.0.2el9.x86_64pigsty4.8 MiBplprql_16-18.0.2-2PGSTY.el9.x86_64.rpm
plprql_1618.0.2el9.aarch64pigsty4.5 MiBplprql_16-18.0.2-2PGSTY.el9.aarch64.rpm
plprql_1618.0.2el10.x86_64pigsty4.8 MiBplprql_16-18.0.2-2PGSTY.el10.x86_64.rpm
plprql_1618.0.2el10.aarch64pigsty4.5 MiBplprql_16-18.0.2-2PGSTY.el10.aarch64.rpm
postgresql-16-plprql18.0.2d12.x86_64pigsty3.1 MiBpostgresql-16-plprql_18.0.2-2PGSTY~bookworm_amd64.deb
postgresql-16-plprql18.0.2d12.aarch64pigsty2.7 MiBpostgresql-16-plprql_18.0.2-2PGSTY~bookworm_arm64.deb
postgresql-16-plprql18.0.2d13.x86_64pigsty3.1 MiBpostgresql-16-plprql_18.0.2-2PGSTY~trixie_amd64.deb
postgresql-16-plprql18.0.2d13.aarch64pigsty2.7 MiBpostgresql-16-plprql_18.0.2-2PGSTY~trixie_arm64.deb
postgresql-16-plprql18.0.2u22.x86_64pigsty3.5 MiBpostgresql-16-plprql_18.0.2-2PGSTY~jammy_amd64.deb
postgresql-16-plprql18.0.2u22.aarch64pigsty3.3 MiBpostgresql-16-plprql_18.0.2-2PGSTY~jammy_arm64.deb
postgresql-16-plprql18.0.2u24.x86_64pigsty3.5 MiBpostgresql-16-plprql_18.0.2-2PGSTY~noble_amd64.deb
postgresql-16-plprql18.0.2u24.aarch64pigsty3.3 MiBpostgresql-16-plprql_18.0.2-2PGSTY~noble_arm64.deb
postgresql-16-plprql18.0.2u26.x86_64pigsty3.4 MiBpostgresql-16-plprql_18.0.2-2PGSTY~resolute_amd64.deb
postgresql-16-plprql18.0.2u26.aarch64pigsty3.2 MiBpostgresql-16-plprql_18.0.2-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
plprql_1518.0.2el8.x86_64pigsty4.0 MiBplprql_15-18.0.2-1PGSTY.el8.x86_64.rpm
plprql_1518.0.2el8.aarch64pigsty3.5 MiBplprql_15-18.0.2-1PGSTY.el8.aarch64.rpm
plprql_1518.0.2el9.x86_64pigsty4.8 MiBplprql_15-18.0.2-2PGSTY.el9.x86_64.rpm
plprql_1518.0.2el9.aarch64pigsty4.5 MiBplprql_15-18.0.2-2PGSTY.el9.aarch64.rpm
plprql_1518.0.2el10.x86_64pigsty4.8 MiBplprql_15-18.0.2-2PGSTY.el10.x86_64.rpm
plprql_1518.0.2el10.aarch64pigsty4.5 MiBplprql_15-18.0.2-2PGSTY.el10.aarch64.rpm
postgresql-15-plprql18.0.2d12.x86_64pigsty3.1 MiBpostgresql-15-plprql_18.0.2-2PGSTY~bookworm_amd64.deb
postgresql-15-plprql18.0.2d12.aarch64pigsty2.7 MiBpostgresql-15-plprql_18.0.2-2PGSTY~bookworm_arm64.deb
postgresql-15-plprql18.0.2d13.x86_64pigsty3.1 MiBpostgresql-15-plprql_18.0.2-2PGSTY~trixie_amd64.deb
postgresql-15-plprql18.0.2d13.aarch64pigsty2.7 MiBpostgresql-15-plprql_18.0.2-2PGSTY~trixie_arm64.deb
postgresql-15-plprql18.0.2u22.x86_64pigsty3.5 MiBpostgresql-15-plprql_18.0.2-2PGSTY~jammy_amd64.deb
postgresql-15-plprql18.0.2u22.aarch64pigsty3.3 MiBpostgresql-15-plprql_18.0.2-2PGSTY~jammy_arm64.deb
postgresql-15-plprql18.0.2u24.x86_64pigsty3.5 MiBpostgresql-15-plprql_18.0.2-2PGSTY~noble_amd64.deb
postgresql-15-plprql18.0.2u24.aarch64pigsty3.3 MiBpostgresql-15-plprql_18.0.2-2PGSTY~noble_arm64.deb
postgresql-15-plprql18.0.2u26.x86_64pigsty3.4 MiBpostgresql-15-plprql_18.0.2-2PGSTY~resolute_amd64.deb
postgresql-15-plprql18.0.2u26.aarch64pigsty3.2 MiBpostgresql-15-plprql_18.0.2-2PGSTY~resolute_arm64.deb

Source

pig build pkg plprql;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install plprql;		# install by package name

pig install plprql -v 19;   # install for PG 19
pig install plprql -v 18;   # install for PG 18
pig install plprql -v 17;   # install for PG 17
pig install plprql -v 16;   # install for PG 16
pig install plprql -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION plprql;

Usage

plprql: Use PRQL in PostgreSQL - Pipelined Relational Query Language

plprql enables writing PostgreSQL functions using PRQL (Pipelined Relational Query Language), a modern language that compiles to SQL with a pipeline syntax.

CREATE EXTENSION plprql;

Create Functions with PRQL

CREATE FUNCTION match_stats(int)
RETURNS TABLE(player text, kd_ratio float) AS $$
  from matches
  filter match_id == $1
  group player (
    aggregate {
      total_kills = sum kills,
      total_deaths = sum deaths
    }
  )
  filter total_deaths > 0
  derive kd_ratio = total_kills / total_deaths
  select { player, kd_ratio }
$$ LANGUAGE plprql;

SELECT * FROM match_stats(42);

Execute PRQL Directly

SELECT prql('from matches | filter player == "Player1"')
  AS (id int, match_id int, player text, kills int)
  LIMIT 2;

Use Cursors for Large Results

SELECT prql('from matches | filter player == "Player1"', 'cursor_name');
FETCH 2 FROM cursor_name;

Inspect Compiled SQL

SELECT prql_to_sql('from matches | filter player == "Player1"');

PRQL Syntax Overview

PRQL uses pipeline transformations:

from employees                    # data source
filter department == "Engineering" # row filtering
derive monthly_salary = salary / 12 # computed columns
sort {-monthly_salary}            # sorting (- for descending)
select {name, monthly_salary}     # column projection
take 10                           # limit rows

Limitations

PRQL only supports SELECT statements. For INSERT, UPDATE, and DELETE, use SQL or PL/pgSQL.

Table reader