-------- Original Message --------
> From: Christian Weiske <>
> Date: 19 January 2007 07:12
>=20
> Hello all,
>=20
> The current memory-SparqlEngine implementation is somewhat wrong when
> it comes to OPTIONAL statements that do return no values for some
> variables. Let me explain: Query:=20
> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
> SELECT ?mbox ?name {
> ?x foaf:mbox ?mbox .
> OPTIONAL { ?x foaf:name ?name } .
> }
>=20
> Data:
> @prefix foaf: <http://xmlns.com/foaf/0.1/> .
> _:e foaf:mbox <mailto:ev...@ex...> .
>=20
>=20
> When querying, variable ?mbox is set but ?name is not, since it isn't
> in the database. The correct value of ?name in my eyes is NULL.=20
> SparqlEngine returns an empty string "" which is ambiguous.
>=20
> I opt for changing the unit tests and adapting the sparql engine. Any
> objections?=20
NULL is OK but it's a "soft null" - if a later part of a query wants to
now bind that variable and it didn't match earlier it can.
e.g.
?x foaf:mbox ?mbox .
OPTIONAL { ?x foaf:name ?name } .
OPTIONAL { ?x foaf:nick ?name } .
which sets ?name if there's a foaf:name else tries foaf:nick if ?name
wasn't set before.
What design for unboudn variavbles that you use is up to you.
Some impls just leave ?name as "unbound", some would set it as NULL but
then make sure that a NULL can later be bound to a real RDF term.
Andy
|