- From: Rob Vesse <rav08r@ecs.soton.ac.uk>
- Date: Fri, 19 Oct 2012 12:26:58 -0700
- To: Jan Wielemaker <J.Wielemaker@uva.nl>, <public-sparql-dev@w3.org>
Hi Jan This one is a scoping issue. The Union is a child graph pattern of the main graph pattern and as SPARQL is evaluated bottom up the variable ?o is not in scope within the union and so the bind expressions will always evaluate to no result. If you put the query into the validator at sparql.org (http://www.sparql.org/query-validator.html) and select the SPARQL Algebra option you'll see the following: (base <http://example/base/> (prefix ((: <http://example.org/>)) (project (?s ?p ?o ?z) (join (bgp (triple ?s ?p ?o)) (union (extend ((?z (+ ?o 1))) (table unit)) (extend ((?z (+ ?o 2))) (table unit))))))) Hope this helps makes the scoping clear Rob On 10/19/12 12:03 PM, "Jan Wielemaker" <J.Wielemaker@uva.nl> wrote: >Hi, > >I'm trying to update ClioPatria's SPARQL support to 1.1. I get this >result: > >15 ?- query_test('bind07 - BIND'). >======================== BEGIN 'bind07 - BIND' ========================= >% Parsed "data.ttl" in 0.00 sec; 4 triples >=========================== 'bind07 - BIND' ============================ >TYPE: select(names(s,p,o,z)) >RESULTS: 8; 4 missed, 8 incorrect >MISSED: <http://example.org/s1> <http://example.org/p> "1"^^xsd:integer >NULL . > <http://example.org/s2> <http://example.org/p> "2"^^xsd:integer >NULL . > <http://example.org/s3> <http://example.org/p> "3"^^xsd:integer >NULL . > <http://example.org/s4> <http://example.org/p> "4"^^xsd:integer >NULL . >EXTRA: <http://example.org/s1> <http://example.org/p> "1"^^xsd:integer >"2"^^xsd:integer . > <http://example.org/s1> <http://example.org/p> "1"^^xsd:integer >"3"^^xsd:integer . > <http://example.org/s2> <http://example.org/p> "2"^^xsd:integer >"3"^^xsd:integer . > <http://example.org/s2> <http://example.org/p> "2"^^xsd:integer >"4"^^xsd:integer . > <http://example.org/s3> <http://example.org/p> "3"^^xsd:integer >"4"^^xsd:integer . > <http://example.org/s3> <http://example.org/p> "3"^^xsd:integer >"5"^^xsd:integer . > <http://example.org/s4> <http://example.org/p> "4"^^xsd:integer >"5"^^xsd:integer . > <http://example.org/s4> <http://example.org/p> "4"^^xsd:integer >"6"^^xsd:integer . >======================================================================== > >The query is this: > >PREFIX : <http://example.org/> > >SELECT ?s ?p ?o ?z >{ > ?s ?p ?o . > { BIND(?o+1 AS ?z) } UNION { BIND(?o+2 AS ?z) } >} > >and the data is > >org:s1 org:p 1 . >org:s2 org:p 2 . >org:s3 org:p 3 . >org:s4 org:p 4 . > >Can anyone explain me by which rules the UNION of the two BIND >operations should >be NULL instead of resulting in two alternative answers? > > Thanks --- Jan >
Received on Friday, 19 October 2012 19:28:08 UTC