sparql
sparql
pgsparql : Query SPARQL datasource with SQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4470 | sparql | pgsparql | 1.0 | UTIL | Apache-2.0 | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
----d-- | No | No | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | sparql |
| Requires | plperl plperlu |
| See Also | pgjq pgjwt gzip bzip zstd http pg_net pg_curl |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 18 17 16 15 14 | pgsparql | plperl, plperlu |
| RPM | PIGSTY | 1.0 | 18 17 16 15 14 | pgsparql_$v | - |
| DEB | PIGSTY | 1.0 | 18 17 16 15 14 | postgresql-$v-pgsparql | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el8.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el9.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el9.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el10.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
el10.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
d12.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
d12.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
d13.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
d13.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
u22.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
u22.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
u24.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
u24.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
Source
pig build pkg pgsparql; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pgsparql; # install via package name, for the active PG version
pig install sparql; # install by extension name, for the current active PG version
pig install sparql -v 18; # install for PG 18
pig install sparql -v 17; # install for PG 17
pig install sparql -v 16; # install for PG 16
pig install sparql -v 15; # install for PG 15
pig install sparql -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION sparql CASCADE; -- requires plperl, plperluUsage
Query SPARQL endpoints (e.g., DBpedia/Virtuoso) from PostgreSQL. SPARQL queries are compiled into Postgres views for use in SQL.
Get Properties of a Resource
SELECT * FROM sparql.get_properties('dbpedia', 'http://dbpedia.org/resource/Johann_Sebastian_Bach');Get References to a Resource
SELECT * FROM sparql.get_references('dbpedia', 'http://dbpedia.org/resource/Johann_Sebastian_Bach');Compile SPARQL Query into SQL View
SELECT sparql.compile_query(endpoint, identifier, sparql_query [, grouping]);Parameters:
endpoint– default SPARQL endpoint nameidentifier– SQL identifier for the created function and viewsparql_query– the SPARQL query to compilegrouping– optional array of identifiers to group by (non-grouped columns are aggregated into arrays)
Example
SELECT sparql.compile_query('dbpedia', 'ludwig_van', $$
SELECT ?predicate, ?object
WHERE {
<http://dbpedia.org/resource/Ludwig_van_Beethoven> ?predicate ?object.
}
$$, '{predicate}');
-- Now query via the created view
SELECT * FROM ludwig_van;This creates a function ludwig_van() and a view ludwig_van that queries the SPARQL endpoint and returns results as a SQL table.
Last updated on