- From: Gregory Williams <greg@evilfunhouse.com>
- Date: Tue, 1 Mar 2011 10:23:04 -0500
- To: SPARQL Working Group <public-rdf-dawg@w3.org>
On Mar 1, 2011, at 10:12 AM, Andy Seaborne wrote: > I added the nested FILTER example recently. This is a different difference as it's based on scoping of variables. (Responding to the issue raised in JB-2 as part of ACTION-403.) I had posted an example of where MINUS and NOT EXISTS are different to Jeen's weblog (where he posted JB-2 before sending it to the list): http://jeenbroekstra.blogspot.com/2011/02/implementing-sparql-11-query-first.html?showComment=1297185762180#c1530706422809325453 The difference in my example is based on NOT EXISTS relying on the variable substitution that happens during filter function evaluation: In this example, the ?n variable isn't bound (isn't in scope) in the MINUS block, and so the FILTER inside the MINUS does something different than FILTER inside the NOT EXISTS block. ### Data @prefix : <http://example.com/> . :a :p 1 ; :q 1,2 . :b :p 3.0 ; :q 4.0, 5.0 . ### Query 1: NOT EXISTS PREFIX : <http://example.com/> SELECT * WHERE { ?a :p ?n FILTER NOT EXISTS { ?a :q ?m . FILTER(?n = ?m) } } +------------------------+-----+ | a | n | +------------------------+-----+ | <http://example.com/b> | 3.0 | +------------------------+-----+ ### Query 2: MINUS PREFIX : <http://example.com/> SELECT * WHERE { ?a :p ?n MINUS { ?a :q ?m . FILTER(?n = ?m) } } +------------------------+-----+ | a | n | +------------------------+-----+ | <http://example.com/a> | 1 | | <http://example.com/b> | 3.0 | +------------------------+-----+ .greg
Received on Tuesday, 1 March 2011 15:23:34 UTC