OPTIONAL and BIND/CONCAT conflicting in v1.1.5

48 views
Skip to first unread message

Lee Baylis

unread,
Feb 26, 2013, 5:25:37 PM2/26/13
to 4store-...@googlegroups.com
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

Steve Harris

unread,
Feb 27, 2013, 8:59:02 AM2/27/13
to 4store-...@googlegroups.com
Hm, interesting bug, thanks for the great report!

There's two parts to it, one is a bug in CONCAT(), which I've fixed, the other appears to be a bug in BIND() which is very mysterious.

- Steve

--
You received this message because you are subscribed to the Google Groups "4store-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 4store-support+u...@googlegroups.com.
To post to this group, send email to 4store-sup...@googlegroups.com.
Visit this group at http://groups.google.com/group/4store-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

-- 
Steve Harris
Experian
Registered in England and Wales 653331 VAT # 887 1335 93
80 Victoria Street, London, SW1E 5JL

Steve Harris

unread,
Apr 18, 2013, 11:04:56 AM4/18/13
to 4store-...@googlegroups.com
Unfortunately I don't think anyone knows exactly what the bug is.

It seems to be some sort of interaction with the optimiser thinking some expressions aren't needed when they are, but it's more complex than just that.

- Steve

On 2013-04-18, at 15:46, Douglas Beeson <douglas...@cogeco.com> wrote:

Hi,

I have run into the same bug with GROUP_CONCAT and an OPTIONAL statement that includes two expressions. To reuse Lee's example: 

== Data ==
@prefix foaf:  <http://xmlns.com/foaf/0.1/>.                                                                             
                                                                                                                               
_:a  foaf:givenName       "Alice" .
_:b  foaf:givenName       "Bob" .                                                                                             

_:c  foaf:givenName       "Carol" .

_:a  foaf:knows      _:b .                                                                                                
_:a  foaf:knows      _:c .                                                                                                                                                                                                                       _:b  foaf:knows      _:c .                                                                                         

== Query ==
SELECT ?first (GROUP_CONCAT(DISTINCT ?name ; separator=";") as ?friends) WHERE {
?a foaf:givenName ?first .
OPTIONAL {?a foaf:knows ?b . ?b foaf:givenName ?name}
}
GROUP BY ?first

== Result ==

"Bob" "Carol"
"Carol" "bad lexical cast"
"Alice" "Bob;Carol"

It seems similar, but not quite identical, to Lee's error. The group_concat worked for "Alice", but failed for "Carol" who knows no one (a statement on society? hmmmm...) 

Is there a patch possible for this? I built my version 1.1.5 from the source tarball at http://4store.org/download/.

Thanks! 
doug
Reply all
Reply to author
Forward
0 new messages