CommentResponse:GK-3

From SPARQL Working Group
Jump to: navigation, search

Dear Graham,

> With reference to
> http://www.w3.org/TR/2010/WD-sparql11-query-20100601/#optionals
> http://www.w3.org/2009/sparql/docs/query-1.1/rq25.xml#optionals
>
> I think it would be helpful to add some explanation that
>    P OPTIONAL Q
> and
>    P { OPTIONAL Q }
>
> can yield different results. 

This observation is correct and these are two different queries. Note that the latter is equivalent to

  P { {} OPTIONAL Q }

There is explanation for this equivalence in the current draft at http://www.w3.org/TR/sparql11-query/#OptionalMatching which the group considers sufficient.

> I recognize that to some extent this request 
> challenges the philosophy of what a specification is _for_, and accept that the 
> first purpose of a specification is to specify, but I also think that some level 
> of explanation helps to ensure the specification is properly followed.  In this 
> case, both myself and at least one other experienced developer had not expected 
> there to be a difference.

Although we add as many examples as we can afford, please understand that we can't have separate examples for every special case in the spec. This is what the test cases shall cover. In fact,

 http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional/manifest.ttl

has a number of test cases for OPTIONAL patterns.

> For my own benefit, I've created an explanation based on elements of the query 
> algebra which you are welcome to copy and/or adapt if that is helpful:
> http://code.google.com/p/milarq/wiki/OutstandingIssues#OPTIONAL_in_braces_doesn't_work_as_might_be_expected
> 
> #g

Thanks for this input, which was discussed in the group; at the moment we don't see new information that would warrant an additional example to go to the spec text.

Axel Polleres, on behalf of the SPARQL working group