[redland-dev] Problems with SPARQL's OPTIONAL pattern matching

Attilio Fiandrotti fiandro at tiscali.it
Fri Mar 10 08:57:55 GMT 2006


Hi

i ran some tests on the OPTIONAL matching using latest librdf, raptor 
and rasqal libraries from SVN with the two following SPARQL queries

Query 1)
PREFIX rdf: <http://www.dajobe.org/foaf.rdf> PREFIX foaf: 
<http://xmlns.com/foaf/0.1/> PREFIX dc: 
<http://purl.org/dc/elements/1.1/> SELECT ?name, ?depiction_title WHERE 
{ ?x foaf:name ?name . ?x foaf:depiction ?y . OPTIONAL { ?y dc:title 
?depiction_title } }

Query 2)
PREFIX rdf: <http://www.dajobe.org/foaf.rdf> PREFIX foaf: 
<http://xmlns.com/foaf/0.1/> PREFIX dc: 
<http://purl.org/dc/elements/1.1/> SELECT ?name, ?depiction_title WHERE 
{ ?x foaf:name ?name . ?x foaf:depiction ?y . OPTIONAL { ?y dc:bad_tag 
?depiction_title } }

(note the "bad_tag" in query 2, to simulate missing title predicate for 
the depiction)

And i executed both queries in different ways

* Via roqet
Query 1) Correct output, all variables assigned
Query 2) Correct output, ?depiction_title=NULL

* Via C# bindings
Query 1) Correct output, all variables assigned
Query 2) application crashed because ?depiction_title=NULL

* Via Python bindings
Query 1) Correct output, all variables assigned
Query 2) application crashed because ?depiction_title=NULL

Note that if the OPTIONAL keyword is removed, then Query 2 produces 
empty sets of result, but i never get crashes.
I suppose this is a bindings problem: is this analysis corect?

friendly

Attilio


More information about the redland-dev mailing list