Re: the LHS of OPTIONAL

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 UTC