Reputation: 1066
Hi Guys am trying run a SPARQL query on Virtuoso version 6.1.x. Here is the query:
SPARQL PREFIX fns: <NAMESPACE> SELECT ?birth ?death ?age ?value ?typeId FROM <http://freebaseInc5>
WHERE { fns:m.030pk7c fns:people.person.date_of_birth ?birth; fns:people.deceased_person.date_of_death ?death; BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {?mid fns:common.topic.notable_types ?type . ?type fns:type.object.id ?typeId } .
OPTIONAL {?mid fns:type.object.name ?value FILTER langMatches(lang(?value), "en") }}
I am getting the error complaining about the syntax:
> SQLState: 37000
Message: SQ074: Line 4: SP030: SPARQL compiler, line 2: syntax error at 'BIND' before '('
SPARQL PREFIX fns: <NAMESPACE> SELECT ?birth ?death ?age ?value ?typeId FROM <NAMESPACE>
WHERE { fns:m.030pk7c fns:people.person.date_of_birth ?birth; fns:people.deceased_person.date_of_death ?death; BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {?mid fns:common.topic.notable_types ?type . ?type fns:type.object.id ?typeId } .
OPTIONAL {?mid fns:type.object.name ?value FILTER langMatches(lang(?value), "en") }}
I don't see what the error is; what am I missing?
Upvotes: 0
Views: 2950
Reputation: 85913
Here's your query, with improved formatting, and with the "SPARQL" removed from the beginning, but no other changes:
PREFIX fns: <NAMESPACE>
SELECT ?birth ?death ?age ?value ?typeId
FROM <http://freebaseInc5>
WHERE {
fns:m.030pk7c fns:people.person.date_of_birth ?birth ;
fns:people.deceased_person.date_of_death ?death ;
BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {
?mid fns:common.topic.notable_types ?type .
?type fns:type.object.id ?typeId
} .
OPTIONAL {
?mid fns:type.object.name ?value
FILTER langMatches(lang(?value), "en")
}
}
According to sparql.org's query validator, the query is well formed (which actually suprised me, given the ;
after ?death
, but I guess it's OK after all).
But if I try to run this on DBpedia's endpoint, which runs Virtuoso, (along with a limit 1, just to make sure it's not actually going to use much in the way of resources), I see the error you're talking about:
Virtuoso 37000 Error SP030: SPARQL compiler, line 10: syntax error at 'BIND' before '('
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> PREFIX fns: <NAMESPACE>
SELECT ?birth ?death ?age ?value ?typeId
FROM <http://freebaseInc5>
WHERE {
fns:m.030pk7c fns:people.person.date_of_birth ?birth ;
fns:people.deceased_person.date_of_death ?death ;
BIND(year(?death)-year(?birth) as ?age ) .
OPTIONAL {
?mid fns:common.topic.notable_types ?type .
?type fns:type.object.id ?typeId
} .
OPTIONAL {
?mid fns:type.object.name ?value
FILTER langMatches(lang(?value), "en")
}
}
LIMIT 1
However, if you change the ;
after ?death
to .
, or remove it completely, the query is accepted without any problem.
Upvotes: 2