Hi Thomas, I’ve never used foreign tables in PostgreSQL, so this is all guesswork.
The NOT NULL constraints are added when the column is nullable. Can you define columns as NOT NULL in the foreign table definition? That would remove the constraints. The three aliases for the same table with self-joins is technically speaking necessary to generate correct results, *unless* there is a unique constraint on the columns used in the subject’s URI pattern. You could try the following steps: 1. Download the master snapshot build from http://download.d2rq.org/ . 2. Add “d2rq:containsDuplicates true;” to the definition of your class map. (This pretends that there’s a unique key constraint.) 3. Start the tool with the --fast option. (This enables certain optimisations that are off by default.) The result is probably that there will only be *one* alias, something like: FROM www_fdw_google_search AS T1_www_fdw_google_search There’s no way to tell D2RQ to avoid renaming the table like this. The other thing you could try is using the R2RML preview build that can be downloaded from the same address above, and use an R2RML mapping. You can generate it via generate-mapping. In the R2RML mapping, you will find: rr:table "www.fdw_google_search"; Replace that with a trivial virtual R2RML view: rr:sqlQuery "SELECT * FROM www_fdw_google_search”; And see if that works. Note that the R2RML preview built has a bunch of other problems. For one, the engine generates very inefficient SQL queries. Hope that helps, Richard On 26 Mar 2014, at 16:03, COMTET Thomas <thomas.com...@hei.fr> wrote: > Hello, > > We would like to map a foreign table created with PostGreSQL 9.3. > This foreign table is associated with a foreign data wrapper connected to > google search web service. > The idea is to create a SPARQL End Point with a multitude of web services > with the ability to catch data on the fly (no intermediate storage) > > The table is created as follow, the full documentation is here : > https://github.com/cyga/www_fdw/wiki/Examples > > CREATE FOREIGN TABLE www_fdw_google_search ( > /* parameters used in request */ > q text, > > /* fields in response */ > GsearchResultClass text, > unescapedUrl text, > url text, > visibleUrl text, > cacheUrl text, > title text, > titleNoFormatting text, > content text > ) SERVER www_fdw_server_google_search; > > We experience some issues due to the SQL query generated by D2RQ : > • The data wrapper allows only one parameter in the WHERE clause (q > field as input) but D2RQ adds IS NOT NULL condition for every fields used in > the SPARQL query > • We have tried with D2RQ 0.8.1 and did not manage to remove > these extra conditions > • We have tried with 0.7 version and it works, the WHERE clause > is built with only the requested parameters > Question #1 : Is there a possibility to remove the IS NOT NULL conditions in > 0.8.1 version ? > • The data wrapper is not very tolerant with SQL language and it does > not support the multiple table renaming > • When we use 3 parameters in a SPARQL query mapped in the same > foreign table, the SQL query generated by D2RQ creates T1_table, T2_table and > T3_table as aliases of the the same table. This works with a local table in > PostGreSQL but not with the www_fdw foreign table. > Question #2 : Is there a possibility to disable the table renaming ? > We do not understand why it is necessary to create these extra tables because > the mapping is done on a unique table in PostGreSQL. > > Question #3 : Have you ever tried this kind of configuration between D2RQ and > PostGreSQL Foreign Table ? > > Many thanks > > Thomas C. > > > > ------------------------------------------------------------------------------ > _______________________________________________ > d2rq-map-devel mailing list > d2rq-map-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel ------------------------------------------------------------------------------ _______________________________________________ d2rq-map-devel mailing list d2rq-map-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel