eclipse-rdf4j / rdf4j

Eclipse RDF4J: scalable RDF for Java
https://rdf4j.org/
BSD 3-Clause "New" or "Revised" License
363 stars 164 forks source link

Federation not compatible with RDF 1.0 endpoints #911

Closed avataar closed 7 years ago

avataar commented 7 years ago

When a federated query is sent to the remote endpoint bindings are replaced with their values, e.g.

PREFIX literal: <http://www.essepuntato.it/2010/06/literalreification/>

SELECT * { 
    BIND("http://dx.doi.org/10.1038/bjc.2014.407" AS ?doi)
    SERVICE <http://opencitations.net/sparql> {
        ?identifier literal:hasLiteralValue ?doi .
    }
}

will be rewritten to (before being sent to the remote end):

PREFIX literal: <http://www.essepuntato.it/2010/06/literalreification/>

SELECT ?identifier { 
    ?identifier literal:hasLiteralValue "http://dx.doi.org/10.1038/bjc.2014.407"^^<http://www.w3.org/2001/XMLSchema#string> .
}

This will work only if the remote endpoint supports RDF 1.1 (where simple literals are always datatyped xsd:string) but it won't return any results if the endpoint is RDF 1.0 (where simple literals have no datatype)

avataar commented 7 years ago

Identified an additional case (where multiple literals are rewritten with a VALUES block instead of expanded into the query proper). Last commit removes some duplicated code in RepositoryFederatedService and now all (hopefully) value-to-SPARQL-string conversion takes place in QueryStringUtil. Also added basic sanity unit tests.