Skip to content

Pillar 2 — Semantic query (SPARQL 1.1)

pgrdf.sparql(q TEXT) → SETOF JSONB parses SPARQL with spargebra, translates the algebra to dynamic SQL against the hexastore quad tables, executes it, and yields one JSONB row per solution.

Solution variables become JSONB keys; unbound variables come through as null.

Surface in this pillar

At a glance

sql
-- Multi-pattern join with a FILTER and a solution modifier.
SELECT * FROM pgrdf.sparql(
  'PREFIX foaf: <http://xmlns.com/foaf/0.1/>
   SELECT ?s ?n
     WHERE { ?s foaf:name ?n .
             ?s <http://example.com/age> ?age
             FILTER(?age >= 30) }
   ORDER BY ?n LIMIT 50');

Next — BGP joins →

Apache-2.0 licensed. Documentation for pgRDF — built with VitePress, served via GitHub Pages.