Re: description of WITH

Hi Axel,

It's possible that I may have stated the wrong thing in the past,
though I'd have to look at each email in detail to see if I have. So
if there's any confusion, it could well be my fault.

That said....

On Tue, May 3, 2011 at 9:14 PM, Axel Polleres <axel.polleres@deri.org> wrote:
> Note, I am mildly worried about that this rewritten text now means that
> WITH is *not* only a macro for GRAPH (which was what I had understood)
>
> take:
>
>  WITH <g>
>  INSERT { ?s ?p ?o }
>  USING <g1>
>  USING NAMED <g>
>  WHERE { ?s ?p ?o }

There is a USING and a USING NAMED here. These create a dataset for
the WHERE clause to be evaluated against. Specifically:
- a default consisting of g1
- a pair <IRI,graph> which is described with "g"

Since the BGP in the WHERE clause does not have a GRAPH modifier, then
it will be resolved against the default graph (g1).

> my understanding was that this would be equivalent to:
>
> 1)
>  INSERT { GRAPH <g> ?s ?p ?o }   <- here <g> points to <g> in GS
>  USING <g1>
>  USING NAMED <g>
>  WHERE { GRAPH <g> ?s ?p ?o }    <- here <g> points to <g> in the dataset described by the UsingClauses
>
> i.e. WITH <g> would not interfer with USING at all, but just expand any non-GRAPH pattern to GRAPH <g>

I'd say the (effective) equivalent is:
INSERT { GRAPH <g> ?s ?p ?o }
WHERE { GRAPH <g1> ?s ?p ?o }

I realize there is an issue here, in that not everyone agrees that I
can use GRAPH if the name is not in a USING NAMED. (I thought I could,
but since I was challenged on it, I haven't parsed the formal
semantics sufficiently to confirm or deny). All the same, it should be
clear that I mean that the WHERE clause will be resolved against the
data in g1.

> in your understanding though, this would rather be equivalent to something like:
>
> 2)
>  INSERT { GRAPH <g> ?s ?p ?o } <- here <g> points to <g> in GS
>  USING <g1>
>  USING NAMED <g>
>  WHERE { ?s ?p ?o }
>
> can you confirm this?

Yes.

> The problem is that the treatment of option 2 might need some
> extra care/explanation in the formal semantics section, i.e. I need to re-check this, since
> that section was now was written in the understanding that WITH is pure syntactic sugar for
> adding GRAPH.
>
> I personally think behavior 1) is more intuitive, but I can live with 2) if it is what the majority wants
> and my understanding 1) was a misunderstanding.

1 doesn't seem intuitive to me at all. The original WHERE clause has
no GRAPH modifier, so the pattern will be resolved against the default
graph. The USING clause specifies the default graph (as per the
definition of FROM in
http://www.w3.org/2009/sparql/docs/query-1.1/rq25.xml#specifyingDataset).

WITH was just supposed to be a shorthand, so that that if everything
(or even just most things) were coming-from/going-into the same place,
then you could avoid the need for repeating GRAPH everywhere. e.g.

WITH <g>
INSERT { ?s rdf:type rdfs:Resource }
WHERE { ?s ?p ?o }

> I am too tired now to check in detail, but unless 1) is unacceptable
> for you, I could come up with a wording suggestion that covers this
> tomorrow morning.

Well, it's not how I see it. But Andy is far more aware of the
semantics than I am, so I will defer to his judgement (sorry to put
you on the spot Andy).


Regards,
Paul

> As far as I understand it, both 1) and 2) are in principle compatible with what is said in Section 4, since with is only mentioned
> before Table 1. It might be good though, if we could add *explicit* rewriting rules for
> WITH (reflecting either understanding 1) or 2) into Table 1, I will go with the majority among Andy and Paul here).
>
> I understand that if Andy, Paul and myself agree on those, we could still add them under the
> resolution to publish modulo ACTION-454... to be on the safe side, I would also ask Greg to approve.
> Please anyone with different opinion, please shout!
>
> I am sorry for that, but I didn't realize that I had a different understanding than Paul here.
>
> Axel
>
> On 3 May 2011, at 15:58, Paul Gearon wrote:
>
>> The previous text for the use of WITH was previously:
>>
>> That is, the GroupGraphPattern in the WHERE clause will be matched
>> against the dataset described by explicit USING or USING NAMED
>> clauses, if specified, and against the graph store otherwise. Any
>> graph name specified in a WITH clause will - for evaluating the WHERE
>> clause - refer to either the default graph of that explicitly defined
>> dataset, or to the default graph of the graph store, respectively (in
>> the absence of USING or USING NAMED clauses).
>>
>>
>> This was unclear for me, since an explicitly defined dataset
>> (described with the USING/USING NAMED keywords) will already have a
>> default graph if there are USING keywords present. So I would like to
>> propose calling out the various scenarios:
>>
>>
>> That is, the GroupGraphPattern in the WHERE clause will be matched
>> against the dataset described by explicit USING or USING NAMED
>> clauses, if specified, and against the graph store otherwise. Any
>> graph name specified in a WITH clause will - for evaluating the WHERE
>> clause - refer to the default graph to be used in the absence of USING
>> or USING NAMED clauses. In the presence of one or more graphs referred
>> to in USING clauses, the default graph will be the merge of these
>> graphs, meaning that the graph in a WITH clause will be ignored while
>> evaluating the WHERE clause. If there is no USING clause, but there is
>> one of more USING NAMED clauses, then the dataset will include a
>> default graph specified by the WITH clause, if present, or an empty
>> graph otherwise.
>>
>>
>>
>> Paul Gearon
>>
>
>

Received on Wednesday, 4 May 2011 02:00:44 UTC