Syntax issues, UNION and MINUS

In SPARQL 1.0,

{ A {B} UNION {C} }

where A, B, C are basic graph patterns

e.g:

{ :x :p ?v {?v :q1 ?v1} UNION {?v :q2 ?v2 } }

parses as:

   group of
     A
     {B} UNION {C}

   group of
     BGP(:x :p ?v)
     BGP(?v :q1 ?v1) UNION BGP(?v :q2 ?v2)


which becomes the algebra:

join(
   A
   union(B,C)
     )


We discussed enabling a simpler form of UNION which might look like:

{ X UNION {Y} }

omitting the {} on the LHS.

To be fully compatible with SPARQL 1.0

{ {A} B UNION {C} }

is still :
join(
   A
   union(B,C)
     )

[Caution: There is a bug in the current SPARQL 1.1 grammar here]

In SPARQL 1.0, OPTIONAL behaves differently: it extends whatever is in 
the group at that point in the paring process:

{ A {B} OPTIONAL {C} }

so the LHS of the OPTIONAL  is "A {B}" or:

group of
   A
   {B}
   OPTIONAL {C}

which is the algebra:

leftjoin(
   join(A,B)
   C
   )

{ :x :p ?v {?v :q1 ?v1} OPTIONAL {?v :q2 ?v2 } }
=>
  leftJoin(
   join(BGP(:x :p ?v), BGP(?v :q1 ?v1))
   C
   )


The question is what is MINUS?  Is it like UNION or like OPTIONAL?


{ A {B} MINUS {C} }

Either:
   minus(
      join(A,B)
      C
     )

or

   join(
     A
     minus(B,C)
     )

{ :x :p ?v {?v :q1 ?v1} MINUS {?v :q2 ?v2 } }

=>
  minus(
   join(BGP(:x :p ?v), BGP(?v :q1 ?v1))
   C
   )

or
   join(
     BGP(:x :p ?v)
     minus(BGP(?v :q1 ?v1), BGP({?v :q2 ?v2)
       )

and whether a form of MINUS which is

   { {A} B MINUS {C} }

should allowed and whether it has the expected meaning (and what do we 
expect it to mean).

 Andy

Received on Monday, 14 June 2010 11:28:34 UTC