Search code examples
sparqlrdfdbpediavirtuoso

Virtuoso SPARQL Bug with BIND


I think I found a bug with the BIND function of SPARQL in Virtuoso. I am running this in http://dbpedia.org/snorql/

Consider the following code:

SELECT DISTINCT ?label ?companyShort
WHERE{
        ?org rdf:type dbo:Company ;
            rdfs:label ?label .        
        #BIND (UCASE(SUBSTR(?label,1,3)) as ?companyShort)
        filter langMatches( lang(?label), "EN" )
        filter(?label="About.com"@en)
}

This behaves as expected. Now remove the comment on the BIND and poof the results vanish. Why would the results vanish if I bind some string manipulation to another variable?


Solution

  • Others may provide the reason for this behavior, but you can fix it by changing the label filter to str(?label)="About.com", so the query would look as follows:

    SELECT DISTINCT ?label ?companyShort
    WHERE{
            ?org rdf:type dbo:Company ;
                rdfs:label ?label .        
            BIND (UCASE(SUBSTR(?label,1,3)) as ?companyShort)
            filter langMatches( lang(?label), "EN" )
            filter(str(?label)="About.com")
    }