Hi,
I have come across some unexpected behaviour when using variables from multiple OPTIONAL statements in conjunction with BIND and CONCAT.
Instead of CONCAT joining two literals and binding them to a variable, the string "bad lexical cast" is appearing in place of the first literal.
Through testing I have stripped my triples/sparql combo down, and the following (which is not my use case ;) ) reproduces my issue.
If I tweak the query to only contain one OPTIONAL statement it is OK, or if I use variables from outside the OPTIONAL statements there is also no problem. If I mix one literal and one URI (foaf:homepage, for example) the CONCAT works fine as well.
triples:
@prefix foaf: <
http://xmlns.com/foaf/0.1/>.
_:a foaf:name "Alice Alpha" .
_:b foaf:name "Bob Bravo" .
_:b foaf:familyName "Bravo" .
_:c foaf:name "Carol Charlie" .
_:c foaf:givenName "Carol" .
sparql:
PREFIX : <
http://example/>
PREFIX foaf: <
http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name ?fname ?gname ?tpage
WHERE {
?x foaf:name ?name .
OPTIONAL {?x foaf:givenName ?gname} .
OPTIONAL {?x foaf:familyName ?fname} .
BIND (CONCAT(?gname, ?name) AS ?tpage) .
}
Thanks for any help!
Lee