You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Tim Harsch <ha...@yahoo.com> on 2011/09/24 01:04:39 UTC
Syntax.SPARQL_11 doesn't recognize COUNT
I'm trying to create some code that will tell me if a query is SPARQL 1.1 or SPARQL 1.0 by first parsing with the 1.0 parser and failing that parse with the 1.1 parser. But the following fails:
QueryFactory.create("SELECT COUNT(*) {}",Syntax.syntaxSPARQL_11);
com.hp.hpl.jena.query.QueryParseException: Encountered " "count" "COUNT "" at line 1, column 8.
Was expecting one of:
<VAR1> ...
<VAR2> ...
"distinct" ...
"reduced" ...
"(" ...
"*" ...
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
<...SNIP...>
Re: Syntax.SPARQL_11 doesn't recognize COUNT
Posted by Andy Seaborne <an...@apache.org>.
Syntax.syntaxARQ does not require such naming (well, it invents one that
is an (illegal, to avoid classhes) varname like ?.1).
Sending the results in a standard format with proper names does require
a name of some kind and, if you had multiple aggregates, then there is a
minor issue of how the app finds out the name generated for the aggregate.
But, as noted on the Dryad blog, it's all a bit of an inconvenience for
some usages like poking around in unknown data.
Andy
On 24/09/11 16:36, Tim Harsch wrote:
> Oh good. I was hoping there was just something I wasn't seeing. I didn't know that SPARQL 1.1 required aggregates with no alias.
>
> Thanks Damian!!
>
>
>
> ----- Original Message -----
>> From: Damian Steer<d....@bristol.ac.uk>
>> To: jena-users@incubator.apache.org; Tim Harsch<ha...@yahoo.com>
>> Cc:
>> Sent: Friday, September 23, 2011 5:09 PM
>> Subject: Re: Syntax.SPARQL_11 doesn't recognize COUNT
>>
>>
>> On 24 Sep 2011, at 00:04, Tim Harsch wrote:
>>
>>> I'm trying to create some code that will tell me if a query is SPARQL
>> 1.1 or SPARQL 1.0 by first parsing with the 1.0 parser and failing that parse
>> with the 1.1 parser. But the following fails:
>>>
>>>
>>> QueryFactory.create("SELECT COUNT(*) {}",Syntax.syntaxSPARQL_11);
>>>
>>> com.hp.hpl.jena.query.QueryParseException: Encountered "
>> "count" "COUNT "" at line 1, column 8.
>>> Was expecting one of:
>>> <VAR1> ...
>>> <VAR2> ...
>>> "distinct" ...
>>> "reduced" ...
>>> "(" ...
>>> "*" ...
>>>
>>> at
>> com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
>>> <...SNIP...>
>>>
>>
>> Oops, I read your emails in the wrong order :-)
>>
>> You need (COUNT(*) AS ?count).
>>
>> Damian
>>
Re: Syntax.SPARQL_11 doesn't recognize COUNT
Posted by Tim Harsch <ha...@yahoo.com>.
Oh good. I was hoping there was just something I wasn't seeing. I didn't know that SPARQL 1.1 required aggregates with no alias.
Thanks Damian!!
----- Original Message -----
> From: Damian Steer <d....@bristol.ac.uk>
> To: jena-users@incubator.apache.org; Tim Harsch <ha...@yahoo.com>
> Cc:
> Sent: Friday, September 23, 2011 5:09 PM
> Subject: Re: Syntax.SPARQL_11 doesn't recognize COUNT
>
>
> On 24 Sep 2011, at 00:04, Tim Harsch wrote:
>
>> I'm trying to create some code that will tell me if a query is SPARQL
> 1.1 or SPARQL 1.0 by first parsing with the 1.0 parser and failing that parse
> with the 1.1 parser. But the following fails:
>>
>>
>> QueryFactory.create("SELECT COUNT(*) {}",Syntax.syntaxSPARQL_11);
>>
>> com.hp.hpl.jena.query.QueryParseException: Encountered "
> "count" "COUNT "" at line 1, column 8.
>> Was expecting one of:
>> <VAR1> ...
>> <VAR2> ...
>> "distinct" ...
>> "reduced" ...
>> "(" ...
>> "*" ...
>>
>> at
> com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
>> <...SNIP...>
>>
>
> Oops, I read your emails in the wrong order :-)
>
> You need (COUNT(*) AS ?count).
>
> Damian
>
Re: Syntax.SPARQL_11 doesn't recognize COUNT
Posted by Damian Steer <d....@bristol.ac.uk>.
On 24 Sep 2011, at 00:04, Tim Harsch wrote:
> I'm trying to create some code that will tell me if a query is SPARQL 1.1 or SPARQL 1.0 by first parsing with the 1.0 parser and failing that parse with the 1.1 parser. But the following fails:
>
>
> QueryFactory.create("SELECT COUNT(*) {}",Syntax.syntaxSPARQL_11);
>
> com.hp.hpl.jena.query.QueryParseException: Encountered " "count" "COUNT "" at line 1, column 8.
> Was expecting one of:
> <VAR1> ...
> <VAR2> ...
> "distinct" ...
> "reduced" ...
> "(" ...
> "*" ...
>
> at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
> <...SNIP...>
>
Oops, I read your emails in the wrong order :-)
You need (COUNT(*) AS ?count).
Damian