- From: Andy Seaborne <andy.seaborne@epimorphics.com>
- Date: Thu, 18 Oct 2012 11:26:50 +0100
- To: public-sparql-dev@w3.org, J.Wielemaker@uva.nl
On 16/10/12 20:25, Jan Wielemaker wrote: > Working through the SPARQL 1.1 testcases for ClioPatria, I'm > struggling with MINUS. This seems to boil down to what do to with > optional bindings (NULL) in the minus arguments. If I treat them to > match everything, I get no results. If treat them to match only > another NULL, I also get ?a = :a2. Can anyone explain what I am > missing? The test is negation/full-minuend.rq The test results are: ------------------- | a | b | c | =================== | :a0 | :b0 | :c0 | | :a3 | :b3 | :c3 | ------------------- What I get is: select ?a ?b ?c { ?a :p1 ?b; :p2 ?c ==> ------------------- | a | b | c | =================== | :a3 | :b3 | :c3 | | :a2 | :b2 | :c2 | | :a1 | :b1 | :c1 | | :a0 | :b0 | :c0 | ------------------- select * { ?d a :Sub OPTIONAL { ?d :q1 ?b } OPTIONAL { ?d :q2 ?c } } ==> ------------------- | d | b | c | =================== | :d3 | :b3 | :cx | | :d2 | :b2 | | | :d1 | :b1 | :c1 | | :d0 | | | ------------------- :a3 is in the solution because so we are doing ------------------- | a | b | c | =================== | :a3 | :b3 | :c3 | | :a2 | :b2 | :c2 | | :a1 | :b1 | :c1 | | :a0 | :b0 | :c0 | ------------------- MINUS ------------------- | d | b | c | =================== | :d3 | :b3 | :cx | | :d2 | :b2 | | | :d1 | :b1 | :c1 | | :d0 | | | ------------------- http://www.w3.org/TR/sparql11-query/#defn_algMinus Let's look at the solution where ?a=:a3 ?b=:b3 ?c=:c3 (?b=:b3 ?c=:c3) does not match (=join with) (?b=:b3 ?c=:cx) because ?c is different. (?b=:b2) is different in ?b (?b=:b1 ?c=:c1) is different in ?b and in ?c (?b=undef, ?c=undef) is covered by "dom(μ) and dom(μ') are disjoint" part of the definition. This exist because otherwise you end up removing everything with two unrelated results using MINUS. (c.f. SQL column compatibility rules) Repeat for the other 3 rows. Andy > For your convenience: the test is: > > prefix : <http://example/> > > select ?a ?b ?c { > ?a :p1 ?b; :p2 ?c > MINUS { > ?d a :Sub > OPTIONAL { ?d :q1 ?b } > OPTIONAL { ?d :q2 ?c } > } > } > order by ?a > > and the data > > ============================== > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . > @prefix example: <http://example/> . > > example:a0 > example:p1 example:b0 ; > example:p2 example:c0 . > > example:a1 > example:p1 example:b1 ; > example:p2 example:c1 . > > example:a2 > example:p1 example:b2 ; > example:p2 example:c2 . > > example:a3 > example:p1 example:b3 ; > example:p2 example:c3 . > > example:d0 > a example:Sub . > > example:d1 > a example:Sub ; > example:q1 example:b1 ; > example:q2 example:c1 . > > example:d2 > a example:Sub ; > example:q1 example:b2 . > > example:d3 > a example:Sub ; > example:q1 example:b3 ; > example:q2 example:cx . > ==============================
Received on Thursday, 18 October 2012 10:27:24 UTC