Skip to content

Commit

Permalink
Add example for rdf_fdw_clone_table() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjonesbr committed Mar 11, 2024
1 parent 3397cdc commit 090f18d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/dbpedia-cities-table-cloning.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
CREATE SERVER dbpedia
FOREIGN DATA WRAPPER rdf_fdw
OPTIONS (endpoint 'https://dbpedia.org/sparql');

CREATE FOREIGN TABLE public.cities (
uri text OPTIONS (variable '?city', nodetype 'iri'),
city_name text OPTIONS (variable '?name', nodetype 'literal', literaltype 'xsd:string'),
area numeric OPTIONS (variable '?area', nodetype 'literal', literaltype 'xsd:double')
)
SERVER dbpedia OPTIONS (
log_sparql 'false',
sparql '
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
{
{
SELECT ?city ?name ?area
{?city a dbo:City ;
foaf:name ?name .
OPTIONAL {?city dbo:areaTotal ?area}
} ORDER BY ASC(?name)
}
}
');

/*
* materilizes all records from the FOREIGN TABLE 'public.cities' in
* the table 'public.cities_local' - retrieving 5000 records at a time.
*/

CALL rdf_fdw_clone_table(
foreign_table => 'cities',
target_table => 'cities_local',
create_table => true,
fetch_size => 5000,
orderby_column => NULL,
verbose => true);

SELECT count(*) FROM cities_local;

0 comments on commit 090f18d

Please sign in to comment.