Hi,

I noticed some interesting results when using SERVICE with a sub query with a slice (limit / offset).


Preliminary Remark:

Because SPARQL semantics is bottom up, a query such as the following will not yield bindings for ?x:

SELECT * {
  SERVICE <https://dbpedia.org/sparql> { SELECT * { ?s a <http://dbpedia.org/ontology/MusicalArtist> } LIMIT 5 }
  SERVICE <https://dbpedia.org/sparql> { BIND(?s AS ?x) }
}


Query engines, such as Jena, attempt to optimize execution. For instance, in the following query,

instead of retrieving all labels, jena uses each binding for a Musical Artist to perform a lookup at the service.

The result is semantically equivalent to bottom up evaluation (without result set limits) - just much faster.

SELECT * {
  SERVICE <https://dbpedia.org/sparql> { SELECT * { ?s a <http://dbpedia.org/ontology/MusicalArtist> } LIMIT 5 }   SERVICE <https://dbpedia.org/sparql> { ?s <http://www.w3.org/2000/01/rdf-schema#label> ?x }
}


The main point:

However, the following query with ARQ interestingly yields one binding for every musical artist - which contradicts the bottom-up paradigm:

SELECT * {
  SERVICE <https://dbpedia.org/sparql> { SELECT * { ?s a <http://dbpedia.org/ontology/MusicalArtist> } LIMIT 5 }   SERVICE <https://dbpedia.org/sparql> { SELECT * { ?s <http://www.w3.org/2000/01/rdf-schema#label> ?x } LIMIT 1 }
}


<http://dbpedia.org/resource/Aarti_Mukherjee> "Aarti Mukherjee"@en
<http://dbpedia.org/resource/Abatte_Barihun> "Abatte Barihun"@en
... 3 more results ...


With bottom-up semantics, the second service clause would only fetch a single binding so in the unlikely event that it happens to join with a musical artist I'd expect at most one binding

in the overall result set.

Now I wonder whether this is a bug or a feature.

I know that Jena's VarFinder is used to decide whether to perform a bottom-up evaluation using OpJoin or a correlated join using OpSequence which results in the different outcomes.

The SPARQL spec doesn't say much about the semantics of Service (https://www.w3.org/TR/sparql11-query/#sparqlAlgebraEval)

So I wonder which behavior is expected when using SERVICE with SLICE'd queries.


Cheers,

Claus


--
Dipl. Inf. Claus Stadler
Institute of Applied Informatics (InfAI) / University of Leipzig
Workpage & WebID: http://aksw.org/ClausStadler

Reply via email to