In the DBpedia SPARQL endpoint, running
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
SELECT ?a (3+3 AS ?y)
WHERE
{
?a dc:description "English footballer" .
?a dbpedia2:placeOfBirth :Merseyside .
}
Shows all English Footballers
who were born in Merseyside, with column y
just displaying the value 6
on every row [result link]; however, the same query on the SNORQL endpoint displays an error:
Virtuoso 37000 Error SP030: SPARQL compiler, line 16: syntax error at '3'
before 'AS' SPARQL query: define sql:big-data-const 0 #output-
format:application/sparql-results+json define input:default-graph-uri PREFIX
owl: PREFIX xsd: PREFIX rdfs: PREFIX rdf: PREFIX foaf: PREFIX dc: PREFIX :
PREFIX dbpedia2: PREFIX dbpedia: PREFIX skos: PREFIX pos: PREFIX dbo: SELECT
?a (3 3 AS ?y) WHERE { ?a dc:description "English footballer" . ?a
dbpedia2:placeOfBirth :Merseyside . }
Even more strangely, using any of the other 3 arithmetic operators does work in the SNORQL endpoint (e.g. with division)
A previous question has implied that the SPARQL and SNORQL endpoints should return the same result, so what's going on here?!
The snorql code used the 'escape' javascript function which is not the correct function to encode a piece of text that needs to be embedded as an parameter argument to the official /sparql endpoint.
This caused the + character to be transferred as literal, and decoded by the /sparql endpoint as a space character, altering the syntax of your query.
We fixed the snorql code on dbpedia.org to use the encodeURIComponent as in:
url = url + '&query=' + encodeURIComponent(query_text);