pg_liquid

Liquid-inspired Datalog graph query extension for PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
pg_liquid0.1.7FEATMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
2610pg_liquidNoYesNoYesNoNoliquid
Relatedage jsquery pg_jsonschema pg_search

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.1.71817161514pg_liquid-
RPMPIGSTY0.1.71817161514pg_liquid_$v-
DEBPIGSTY0.1.71817161514postgresql-$v-pg-liquid-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
u22.x86_64
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
u22.aarch64
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
u24.x86_64
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
u24.aarch64
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7
PIGSTY 0.1.7

Build

You can build the RPM / DEB packages for pg_liquid using pig build:

pig build pkg pg_liquid         # build RPM / DEB packages

Install

You can install pg_liquid directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install pg_liquid;          # Install for current active PG version
pig ext install -y pg_liquid -v 18  # PG 18
pig ext install -y pg_liquid -v 17  # PG 17
pig ext install -y pg_liquid -v 16  # PG 16
pig ext install -y pg_liquid -v 15  # PG 15
pig ext install -y pg_liquid -v 14  # PG 14
dnf install -y pg_liquid_18       # PG 18
dnf install -y pg_liquid_17       # PG 17
dnf install -y pg_liquid_16       # PG 16
dnf install -y pg_liquid_15       # PG 15
dnf install -y pg_liquid_14       # PG 14
apt install -y postgresql-18-pg-liquid   # PG 18
apt install -y postgresql-17-pg-liquid   # PG 17
apt install -y postgresql-16-pg-liquid   # PG 16
apt install -y postgresql-15-pg-liquid   # PG 15
apt install -y postgresql-14-pg-liquid   # PG 14

Create Extension:

CREATE EXTENSION pg_liquid;

Usage

Source: Docs site, README, Release v0.1.7, SQL install script

pg_liquid brings Liquid-style graph and compound queries into PostgreSQL. It stores graph state in the liquid schema and exposes SQL entry points for plain queries, principal-bound queries, and least-privilege reads.

Core query surface

CREATE EXTENSION pg_liquid;

SELECT *
FROM liquid.query($$
  Edge("a","b").
  Edge("b","c").
  Path(X,Y) :- Edge(X,Y).
  Path(X,Y) :- Edge(X,Z), Path(Z,Y).
  Path("a",Y)?
$$) AS t(y text);
  • liquid.query(program text): executes Liquid facts, rules, and one terminal query.
  • liquid.query_as(principal text, program text): principal-bound execution.
  • liquid.read_as(principal text, program text): least-privilege read wrapper; intended for application-facing reads.

Language and modeling features

  • facts and rules terminated by .
  • one terminal ? query per program
  • graph edges via Edge(...)
  • typed compounds such as Type@(role=value, ...)
  • query-local recursive rules
  • built-in policy compounds such as CompoundReadByRole and liquid/acts_for

Row normalizers

SELECT liquid.create_row_normalizer(
  'account_profiles'::regclass,
  'account_profile_normalizer',
  'AccountProfile',
  '{"account_id":"id","display_name":"display_name","tier":"tier"}'::jsonb,
  true
);
  • liquid.create_row_normalizer(...): projects relational rows into Liquid compounds.
  • liquid.rebuild_row_normalizer(...): regenerates bindings after table changes.
  • liquid.drop_row_normalizer(...): removes the normalizer and optionally purges generated bindings.

Caveats

  • Upstream validates the extension on PostgreSQL 14 through 18.
  • query_as and read_as are revoked from PUBLIC in the shipped SQL; grant them deliberately.
  • read_as(...) is the safer application entry point when clients should not assert new facts.

Last Modified 2026-04-19: update extension stub docs (9f178c3)