rdf_fdw

Foreign data wrapper for RDF triplestores over SPARQL endpoints

Overview

PackageVersionCategoryLicenseLanguage
rdf_fdw2.4.0FDWMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
8760rdf_fdwNoYesNoYesNoYes-
Relatedwrappers multicorn postgres_fdw sparql

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY2.4.01817161514rdf_fdw-
RPMPIGSTY2.4.01817161514rdf_fdw_$v-
DEBPIGSTY2.4.01817161514postgresql-$v-rdf-fdw-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64PIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISS
el8.aarch64PIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISS
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
PIGSTY 2.4.0
PIGSTY 2.4.0
PIGSTY 2.4.0
PIGSTY 2.4.0
PIGSTY 2.4.0
u24.x86_64
u24.aarch64
PIGSTY 2.4.0
PIGSTY 2.4.0
PIGSTY 2.4.0
PIGSTY 2.4.0
PIGSTY 2.4.0

Build

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

pig build pkg rdf_fdw         # build RPM / DEB packages

Install

You can install rdf_fdw 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 rdf_fdw;          # Install for current active PG version
pig ext install -y rdf_fdw -v 18  # PG 18
pig ext install -y rdf_fdw -v 17  # PG 17
pig ext install -y rdf_fdw -v 16  # PG 16
pig ext install -y rdf_fdw -v 15  # PG 15
pig ext install -y rdf_fdw -v 14  # PG 14
dnf install -y rdf_fdw_18       # PG 18
dnf install -y rdf_fdw_17       # PG 17
dnf install -y rdf_fdw_16       # PG 16
dnf install -y rdf_fdw_15       # PG 15
dnf install -y rdf_fdw_14       # PG 14
apt install -y postgresql-18-rdf-fdw   # PG 18
apt install -y postgresql-17-rdf-fdw   # PG 17
apt install -y postgresql-16-rdf-fdw   # PG 16
apt install -y postgresql-15-rdf-fdw   # PG 15
apt install -y postgresql-14-rdf-fdw   # PG 14

Create Extension:

CREATE EXTENSION rdf_fdw;

Usage

Syntax:

CREATE EXTENSION rdf_fdw;
CREATE SERVER dbpedia FOREIGN DATA WRAPPER rdf_fdw
  OPTIONS (endpoint 'https://dbpedia.org/sparql');

Source: README

rdf_fdw is a foreign data wrapper for RDF triplestores exposed through SPARQL endpoints. It lets PostgreSQL query RDF data with SQL, supports SQL clause pushdown, adds an rdfnode type for RDF terms, and includes SPARQL 1.1 function support.

Server Setup

Register a SPARQL endpoint with CREATE SERVER:

CREATE SERVER dbpedia
FOREIGN DATA WRAPPER rdf_fdw
OPTIONS (endpoint 'https://dbpedia.org/sparql');

The README documents server options such as:

  • endpoint (required)
  • batch_size
  • enable_pushdown
  • format
  • http_proxy
  • connect_timeout

Proxy credentials belong in a user mapping.

Foreign Tables

rdf_fdw works by declaring foreign tables that embed SPARQL queries and map result variables to PostgreSQL columns. The README also highlights native RDF node handling through the custom rdfnode type.

Pushdown and DML

The upstream docs specifically call out pushdown for:

  • WHERE
  • LIMIT
  • ORDER BY
  • DISTINCT

They also document data modification support:

  • INSERT
  • UPDATE
  • DELETE

Batching for SPARQL UPDATE traffic is controlled with the batch_size option.

Helper Functions

The README lists utility functions including:

  • rdf_fdw_version()
  • rdf_fdw_settings()
  • rdf_fdw_clone_table()

It also documents broader SPARQL function coverage, including aggregates, string functions, numeric functions, date/time functions, hash functions, and custom functions.

Notes

The current README warns that retrieved RDF data is loaded into memory before conversion for PostgreSQL, so large result sets require adequate PostgreSQL memory. It also documents PostgreSQL 9.5+ as the supported baseline.


Last Modified 2026-04-14: update extension catalog (29617e5)