W3C home > Mailing lists > Public > public-sparql-dev@w3.org > April to June 2016

interaction of GRAPH and sub-SELECT

From: Alexandre Riazanov <ariazanov@systap.com>
Date: Mon, 25 Apr 2016 15:41:37 -0300
Message-ID: <CANK0mJR4+puP2_ZyeeGDLMWgo2w_PF0hQFf6aG1y56caJOw4Jw@mail.gmail.com>
To: public-sparql-dev@w3.org
Hi everybody,

I would appreciate any help on the following problem related to
interpretation of the SPARQL 1.1 standard.

To summarise the issue, it seems that one of the standard tests (
http://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/manifest#subquery03
, a.k.a. sq03) contradicts the spec https://www.w3.org/TR/sparql11-query/ .



In https://www.w3.org/TR/sparql11-query/#sparqlAlgebraEval , the spec says:

> eval(D(G), Graph(var,P)) =
>      Let R be the empty multiset
>      foreach IRI i in D
>         R := Union(R, Join( eval(D(D[i]), P) , Ω(?var->i) )
>      the result is R

Earlier (https://www.w3.org/TR/sparql11-query/#rdfDataset) the spec also
says:

> An RDF Dataset comprises one graph, the default graph, which does not
have a name,
> and zero or more named graphs, where each named graph is identified by an
IRI.

which means that we never consider the default graph as active when we
compute

>      foreach IRI i in D
>         R := Union(R, Join( eval(D(D[i]), P) , Ω(?var->i) )

because the default graph does not have an IRI.



Another definition from
https://www.w3.org/TR/sparql11-query/#sparqlAlgebraEval :

> Definition: Evaluation of Project
> eval(D(G), Project(L, vars)) = Project(eval(D(G), L), vars)

so, in a sense, a GRAPH "distributes" over SELECT.




Now, consider the specific query in
https://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/sq03.rq :


select ?x where {
graph ?g {
  {select ?x where {?x ?p ?g}}
}
}

To leave the issue of variable scoping aside, we can consider an equivalent
query:

select ?x where {
graph ?g1 {
  {select ?x where {?x ?p ?g}}
}
}


The data for the test is
https://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/sq01.rdf:

<rdf:RDF>
  <rdf:Description rdf:about="http://www.example.org/instance#a">
     <ex:p rdf:resource="http://www.example.org/instance#b"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.example.org/instance#c">
     <ex:p rdf:resource=""/>
  </rdf:Description>
</rdf:RDF>

so, there is a default graph with two triples and no named graphs,
therefore, according to the spec, the sub-query is only evaluated on the
named sets <http://www.example.org/instance#a>, <
http://www.example.org/instance#b>, <http://www.example.org/instance#c>, <
http://www.example.org/instance#p> and <>, which are all empty. Therefore,
the pattern ?x ?p ?g is never matched by any triples, the result multisets
of the sub-query are empty, and thus the overall result multiset is empty.


However,
https://www.w3.org/2009/sparql/docs/tests/data-sparql11/subquery/sq03.srx
specifies the result to contain two assignments: {x ->
http://www.example.org/instance#c} and {x ->
http://www.example.org/instance#a}, as if the subquery was evaluated on the
default graph.


Is my reasoning correct (and therefore the test is broken), or I am missing
something? Can anybody shed some light on this?



Cheers,
======================================
Alexandre Riazanov (Alexander Ryazanov), PhD
Saint John, New Brunswick, Canada
Skype: alexandre.riazanov
http://riazanov.webs.com/
http://www.linkedin.com/in/riazanov
tel: +1 506 639 1529
======================================
Received on Tuesday, 26 April 2016 08:47:20 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 26 April 2016 08:47:21 UTC