[SPARQL-Update] WITH, GRAPH, and USING [NAMED]

Hello,

I'm having troubles with a couple of approved DAWG tests for SPARQL-Update
and wonder if my understanding of WITH semantics in 3.1.3 [1] is incorrect.

3.1.3 states that WITH is in effect for the WHERE clause of DELETE/INSERT
queries when there're no USING or USING NAMED clauses. The example in 3.1.3
illustrates how WITH could be de-sugared into GRAPH clauses for
DELETE/INSERT and USING for WHERE, thus defining the RDF Dataset for WHERE.

Let's see what happens if we do the same for a slightly more complex query:

WITH <http://example.org/g2>
DELETE
{
  GRAPH <http://example.org/g1> { ?s ?p ?o }
}
WHERE
{
  GRAPH <http://example.org/g1> { :a foaf:knows ?s . ?s ?p ?o }
}

According to my, perhaps incorrect, reading of 3.1.3 this should be
equivalent to:

DELETE
{
  GRAPH <http://example.org/g1> { ?s ?p ?o }
}
USING <http://example.org/g2> WHERE
{
  GRAPH <http://example.org/g1> { :a foaf:knows ?s . ?s ?p ?o }
}

that is, WITH is ignored for DELETE because there's the explicit GRAPH
clause but applies to WHERE because there's no USING [NAMED]. Then this
query should not delete any triples because the dataset for WHERE is
composed of the empty default graph and :g2 as the only named graph, while
WHERE matches triples in :g2.

However, this is not what DAWG tests [2] expect and it is not how ARQ or
Sesame implement it (they pass the test). What I can tell from ARQ's source
code is that it treats the query as follows:

DELETE
{
  GRAPH <http://example.org/g1> { ?s ?p ?o }
}
{
  GRAPH <http://example.org/g2> {
    GRAPH <http://example.org/g1> { :a foaf:knows ?s . ?s ?p ?o }
  }
}

In this case, of course, WHERE will match triples because the inner GRAPH
will set :g1 as the active graph for the BGP. However 3.1.3 says explicitly
that WITH, when not ignored, defines an RDF Dataset -- this isn't what
happens here.

Another interpretation could be as follows: WITH is in effect for WHERE if
there's no USING [NAMED] *and* there is no GRAPH clause in either DELETE or
INSERT. According to that interpretation the test again should pass because
WITH is simply ignored for the whole query, including WHERE, even though
there's no USING [NAMED].

So the question is: which interpretation is the intended one?

Thanks,
Pavel

[1] https://www.w3.org/TR/sparql11-update/#deleteInsert
[2]
https://www.w3.org/2009/sparql/docs/tests/data-sparql11/delete/manifest#dawg-delete-with-02

Received on Friday, 5 August 2016 07:19:59 UTC