On Wed, Oct 8, 2014 at 10:10 AM, Damian Steer <[email protected]> wrote:
> On 08/10/14 15:06, Julien Plu wrote:
>> I think I found a little bug in the SPARQL parser for Jena 2.12.0. When I
>> run the query :
>>
>> SELECT count(distinct ?s) as ?count WHERE {?s ?p ?o}
>
> You need parentheses around the ... as ...:
>
> SELECT (count(distinct ?s) as ?count) WHERE {?s ?p ?o}

Damien Steer's answer is correct.  Virtuoso (the endpoint that DBpedia
uses) allows a number of things that aren't actually allowed by the
SPARQL standard.  There's a SPARQL validator at sparql.org that might
be useful.  It's based on Jena, though, so if there *were* a bug, the
validator might not catch it.   When in doubt, though, you can check
the SPARQL Grammar [1].  In this case, the important rule

  [9]  SelectClause  ::=  'SELECT' ( 'DISTINCT' | 'REDUCED' )? ( ( Var
| ( '(' Expression 'AS' Var ')' ) )+ | '*' )

which shows that parentheses are needed around the "expression as var"
construction.

//JT

[1] http://www.w3.org/TR/sparql11-query/#sparqlGrammar




-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to