-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for rdf_fdw_clone_table() usage
- Loading branch information
1 parent
3397cdc
commit 090f18d
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |