You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Joshua TAYLOR <jo...@gmail.com> on 2016/03/28 16:42:17 UTC

Odd "parsed result" with group_concat and distinct?

In a Stack Overflow question [1] a user seems to be running up against
a syntax error when running a query from Java that they're not getting
when they run the same query from a Fuseki web interface.  Looking
into it, there's something weird going on, and it shows up in
sparql.org's query parser [2].  If you enter the query

    select (group_concat(distinct ?x) as ?y) (sum(distinct ?x) as ?z) {}

into the parser, the formatted, parsed query appears as:

    SELECT  (GROUP_CONCAT DISTINCT (?x) AS ?y) (SUM(DISTINCT ?x) AS ?z) WHERE {}

which is *not* legal. (Note the off placement of distinct with the
GROUP_CONCAT.)

When a query is sent to a remote endpoint using Jena, does Jena first
parse the input query, and then send the reformatted query off to the
remote endpoint?  That would explain the user's weird experience, but
I'm not sure whether that's how things are implemented or not.

Joshua


[1] http://stackoverflow.com/q/36137483/1281433
[2] http://sparql.org/validate/query

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

Re: Odd "parsed result" with group_concat and distinct?

Posted by Joshua TAYLOR <jo...@gmail.com>.
On Mon, Mar 28, 2016 at 10:46 AM, Lorenz B.
<bu...@informatik.uni-leipzig.de> wrote:
> Hi Joshua,
>
> just what I know about Jena so far:
>
> if a Query object is created first, yes it's parsed and probably converted
> into what you showed as being non-legal SPARQL. The parsing can be avoided
> with QueryEngineHttp which sends the plain query string.

Yeah, that's the approach that Andy has mentioned before on an
answers.semanticweb.com answer [2], and that's what I passed on to the
Stack Overflow user.  It's a really weird bug though, if that's what's
actually happening.

Unfortunately, the user said that he did ask on the Jena mailing list,
and got the same response that I initially provide, "it looks like
you've got a typo, are you **sure** that you're showing us the code
that you're running?".  (I think that's a completely reasonable
response, especially with non-minimal examples, though.)  I wonder if
this has bitten anyone else in recent times?

Joshua

[2] http://answers.semanticweb.com/questions/19935/jena-throws-queryparsingexception-on-correct-but-non-standard-sparql

>
> Kind regards,
> Lorenz
>
>> In a Stack Overflow question [1] a user seems to be running up against
>> a syntax error when running a query from Java that they're not getting
>> when they run the same query from a Fuseki web interface.  Looking
>> into it, there's something weird going on, and it shows up in
>> sparql.org's query parser [2].  If you enter the query
>>
>>      select (group_concat(distinct ?x) as ?y) (sum(distinct ?x) as ?z) {}
>>
>> into the parser, the formatted, parsed query appears as:
>>
>>      SELECT  (GROUP_CONCAT DISTINCT (?x) AS ?y) (SUM(DISTINCT ?x) AS ?z)
>> WHERE {}
>>
>> which is *not* legal. (Note the off placement of distinct with the
>> GROUP_CONCAT.)
>>
>> When a query is sent to a remote endpoint using Jena, does Jena first
>> parse the input query, and then send the reformatted query off to the
>> remote endpoint?  That would explain the user's weird experience, but
>> I'm not sure whether that's how things are implemented or not.
>>
>> Joshua
>>
>>
>> [1] http://stackoverflow.com/q/36137483/1281433
>> [2] http://sparql.org/validate/query
>>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>



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

Re: Odd "parsed result" with group_concat and distinct?

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
Hi Joshua,

just what I know about Jena so far:

if a Query object is created first, yes it's parsed and probably 
converted into what you showed as being non-legal SPARQL. The parsing 
can be avoided with QueryEngineHttp which sends the plain query string.

Kind regards,
Lorenz

> In a Stack Overflow question [1] a user seems to be running up against
> a syntax error when running a query from Java that they're not getting
> when they run the same query from a Fuseki web interface.  Looking
> into it, there's something weird going on, and it shows up in
> sparql.org's query parser [2].  If you enter the query
>
>      select (group_concat(distinct ?x) as ?y) (sum(distinct ?x) as ?z) {}
>
> into the parser, the formatted, parsed query appears as:
>
>      SELECT  (GROUP_CONCAT DISTINCT (?x) AS ?y) (SUM(DISTINCT ?x) AS ?z) WHERE {}
>
> which is *not* legal. (Note the off placement of distinct with the
> GROUP_CONCAT.)
>
> When a query is sent to a remote endpoint using Jena, does Jena first
> parse the input query, and then send the reformatted query off to the
> remote endpoint?  That would explain the user's weird experience, but
> I'm not sure whether that's how things are implemented or not.
>
> Joshua
>
>
> [1] http://stackoverflow.com/q/36137483/1281433
> [2] http://sparql.org/validate/query
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center