W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > October to December 2006

Re: the LHS of OPTIONAL

From: Steve Harris <steve.harris@garlik.com>
Date: Mon, 20 Nov 2006 17:44:10 +0000
Message-Id: <A7431208-1352-4D4E-B7B8-F8EA6F970DFF@garlik.com>
Cc: RDF Data Access Working Group <public-rdf-dawg@w3.org>
To: Lee Feigenbaum <feigenbl@us.ibm.com>


On 20 Nov 2006, at 17:12, Lee Feigenbaum wrote:
...
>
> {
>   { T1 } UNION { T2 } .
>   T3 .
>   OPTIONAL { T4 . }
> }
>
> Is this:
>   Group( Optional( Group( Union(T1, T2), T3), Group(T4) ) ) )
> or
>   Group( Union(T1, T2), Optional( Group(T3), Group(T4) ) )
>
> That is, does OPTIONAL pull in everything before it (but in the same
> group) to form the implicit LHS group, or just the nearest bunch of  
> triple
> patterns and filters? I suspect the former, but find this confusing.

Agreed, it's confusing.

It's always been my opinion that allowing FILTER to be anywhere in  
the query hurts readability.

> Fred Z. and I have both advanced the idea that perhaps SPARQL should
> require that the LHS of the OPTIONAL be explicitly demarcated by  
> mandatory
> curly braces. In our opinion (OK, in my opinion, but I'm guessing Fred
> shares it), this would alleviate any confusion and make complex  
> queries
> more readable.

>> From conversations with Andy, I believe that he disagrees that  
>> mandatory
> curlies would make queries more readable (believing instead that  
> the extra
> curlies would make reading queries more difficult) and he is also  
> worried
> about the significant number of existing SPARQL queries that would  
> become
> invalid.

I agree with Andy here. I've seen a lot of queries like:

T1 .
T2 .
OPTIONAL { T3 }
OPTIONAL { T4 }
OPTIONAL { T5 }

and those would become a real eyeful:

{
   {
     { T1 .
       T2 .
     } OPTIONAL { T3 }
   } OPTIONAL { T4 }
} OPTIONAL { T5 }

Plus, explaining, and implementing the difference between:

{ T1 . T2 . } OPTIONAL { T3 }

and

T1 . { T2 } OPTIONAL { T3 }

is not something I relish.

- Steve
Received on Monday, 20 November 2006 17:44:18 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:27 GMT