So is it this example that causing the confusion?

[[
DELETE { GRAPH <g1> { a b c } } INSERT { GRAPH <g1> { x y z } }
USING <g1> WHERE { ... }
]]

USING does setup the entire dataset whereas WITH just sets the initial active graph for matching but leaves the dataset alone. It is like a

   GRAPH<g>{... the where clause ...}

The example with USING looks wrong to me and at odds with the definitional text for WITH.

USING resets the dataset.  WITH does/should not.

The earlier text is reasonably clear about that.

    Andy


On 05/08/16 16:02, Pavel Klinov wrote:
Apologies, this email was meant to be sent to the list.


---------- Forwarded message ----------
From: *Pavel Klinov* <pa...@complexible.com <mailto:pa...@complexible.com>>
Date: Fri, Aug 5, 2016 at 4:37 PM
Subject: Re: [SPARQL-Update] WITH, GRAPH, and USING [NAMED]
To: Andy Seaborne <a...@apache.org <mailto:a...@apache.org>>


Hi Andy,

On Fri, Aug 5, 2016 at 3:32 PM, Andy Seaborne <a...@apache.org
<mailto:a...@apache.org>> wrote:

    On 05/08/16 09:05, Pavel Klinov wrote:



        On Thu, Aug 4, 2016 at 11:04 PM, Pavel Klinov
        <pa...@complexible.com <mailto:pa...@complexible.com>
        <mailto:pa...@complexible.com <mailto:pa...@complexible.com>>>
        wrote:


            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.


        A correction here: the dataset for WHERE should be :g2 as the
        default
        graph and no named graphs (or unspecified named graphs, as per
        13.2 in
        [3]). But the rest of the email holds, the query can still return no
        results contarry to the test.


    Hi Pavel,
    (not an official reply)

    I believe the intent is that WITH sets the default graph but
    otherwise the named graph are in the dataset visible.


OK, that's a possible interpretation but it's different from wrapping
WHERE in a GRAPH. Either it does something to the dataset or changes the
pattern in WHERE, those are different things.


    Unlike USING, WITH is not describing the whole dataset to use.  Is
    there text that suggested to it did? Or entangles WITH and USING? If
    so, an errata would be in order.


First, there's the snippet you quoted below: "If a graph name is
specified in a WITH clause, then - for the purposes of evaluating the
WHERE clause - this will define an RDF Dataset..."

Second, there's the example in 3.1.3:

[[

To illustrate the use of the WITH clause, an operation of the general form:

WITH <g1> DELETE { a b c } INSERT { x y z } WHERE { ... }
is considered equivalent to:

DELETE { GRAPH <g1> { a b c } } INSERT { GRAPH <g1> { x y z } } USING
<g1> WHERE { ... }

]]

This gives the impression that WITH, when not ignored, is a syntactic
sugar for USING. And since USING has basically the same meaning as FROM,
it should follow that WITH defines the dataset to the extent that FROM
does.

Now, regarding your point that it may leave the set of named graphs
unchanged. Actually 13.2 of the SPARQL spec seems to leave such possibility:

[[
If there is no FROM clause, but there is one or more FROM NAMED clauses,
then the dataset includes an empty graph for the default graph.
]]

See, it doesn't say what the set of named graphs is if there's FROM but
no FROM NAMED (so in our case USING but not USING NAMED). So it's indeed
possible for WITH, when interpreted as USING, to describe only the
default graph. But even then the test with :g1 and :g2 doesn't seem
right because in the absense of defined named graphs, an implementation
doesn't have to include :g1. The dataset <:g2, {}> seems like a valid
implementation choice.


    The later text:
    [[
    If a graph name is specified in a WITH clause, then - for the
    purposes of evaluating the WHERE clause - this will define an RDF
    Dataset containing a default graph with the specified name
    ]]

    look to me to be at odds with:

    [[
    The WITH clause defines the graph that will be modified or matched
    against for any of the subsequent elements (in DELETE, INSERT, or
    WHERE clauses) if they do not specify a graph explicitly.
    ]]

    [[
    That is, a WITH clause may be viewed as syntactic sugar for wrapping
    both the QuadPatterns in subsequent DELETE and INSERT clauses, and
    likewise the GroupGraphPattern in the subsequent WHERE clause into
    GRAPH patterns.
    ]]

    which both suggest your example of:

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

    is intended.


Yes, I agree that the latter two sentences do suggest that. I don't
object against such an interpretation, just trying to confirm what
should be the right behavior.

Thanks again,
Pavel



            Andy


        Thanks,
        Pavel

        [3] https://www.w3.org/TR/sparql11-query/#specDataset
        <https://www.w3.org/TR/sparql11-query/#specDataset>



            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
        <https://www.w3.org/TR/sparql11-update/#deleteInsert>
            <https://www.w3.org/TR/sparql11-update/#deleteInsert
        <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
        
<https://www.w3.org/2009/sparql/docs/tests/data-sparql11/delete/manifest#dawg-delete-with-02>

        
<https://www.w3.org/2009/sparql/docs/tests/data-sparql11/delete/manifest#dawg-delete-with-02
        
<https://www.w3.org/2009/sparql/docs/tests/data-sparql11/delete/manifest#dawg-delete-with-02>>








Reply via email to