No I did not file a specific defect yet, please feel free to log a JIRA
bug if you wish

Rob



On 4/23/13 1:37 PM, "John Liu" <[email protected]> wrote:

>Thanks, Rob for your quick reponse.
> 
>Is there a defect number that I can track this bug?
> 
>Thanks, John
> 
>
>________________________________
> From: Rob Vesse <[email protected]>
>To: "[email protected]" <[email protected]>; John Liu
><[email protected]>
>Sent: Tuesday, April 23, 2013 4:13:51 PM
>Subject: Re: problem in rewriting query by AlgebraGenerator
>  
>
>It's a bug in how OpAsQuery converts sub-queries, watch this space for a
>fix
>
>Rob
>
>
>On 4/23/13 12:35 PM, "John Liu" <[email protected]> wrote:
>
>>oh I see, thanks Rob.
>> 
>>I paste the class here, you will see the exception error when you run the
>>code.
>> import
>>com.hp.hpl.jena.query.Query;import
>>com.hp.hpl.jena.query.QueryFactory;import
>>com.hp.hpl.jena.sparql.algebra.AlgebraGenerator;import
>>com.hp.hpl.jena.sparql.algebra.Op;import
>>com.hp.hpl.jena.sparql.algebra.OpAsQuery;public
>>classTestJena {
>>/*** 
>>@paramargs*/
>>publicstaticvoidmain(String[] args) {String queryString =
>>"PREFIX dcterms: <http://purl.org/dc/terms/> \n"+
>>"PREFIX dbpedia: <http://dbpedia.org/resource/> \n"+
>>"SELECT ?num_of_holidays ?celebrate_Chinese_New_Year  WHERE { \n"+
>>"{"+
>>"SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays) \n"+
>>"WHERE {"+
>>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>>"?holiday dcterms:subject ?country_cat \n"+
>>"}GROUP by ?country_cat \n"+
>>"} \n"+
>>"{ \n"+
>>"SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>\n"+
>>"WHERE { \n"+
>>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>>"?holiday dcterms:subject ?country_cat \n"+
>>"FILTER(?holiday=\"http://dbpedia.org/resource/Lunar_New_Year/'s_Day/")
>>\n"+
>>"}GROUP by ?country_cat \n"+
>>"} \n"+ 
>>"}\n";System.
>>out.println("Original query: \n"+ queryString);Query query =
>>QueryFactory.create(queryString);
>>AlgebraGenerator ag =
>>newAlgebraGenerator();Op op = ag.compile(query);
>>Query query2 = OpAsQuery.asQuery(op);
>>String queryString2 = query2.toString();
>>System.
>>out.println("Update query: \n"+ queryString2);Query newQuery2 =
>>QueryFactory.create(queryString2);
>>}
>>}
>> 
>>
>>________________________________
>> From: Rob Vesse <[email protected]>
>>To: "[email protected]" <[email protected]>
>>Sent: Tuesday, April 23, 2013 2:06:34 PM
>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>  
>>
>>John
>>
>>Apache list strips attachments, if you have a code sample please just
>>paste it into the email or provide a link to a pastebin/similar site with
>>your code sample
>>
>>Rob
>>
>>
>>On 4/23/13 11:02 AM, "John Liu" <[email protected]> wrote:
>>
>>>Thanks Andy for your quick reply.
>>> 
>>>I tested Jena 2.10.1 and the problem still exists. Could you please run
>>>the attached java code to see if it is a defect?
>>> 
>>>Thanks, John
>>> 
>>>
>>>________________________________
>>> From: Andy Seaborne <[email protected]>
>>>To: [email protected]
>>>Sent: Tuesday, April 23, 2013 10:46:25 AM
>>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>>  
>>>
>>>On 23/04/13 03:10, John Liu wrote:
>>>> Hello,
>>>> I found a problem when rewriting a query by AlgebraGenerator, the
>>>> generated query becomes syntax incorrect query. Can you please advise
>>>>if
>>>> this is a defect? Thanks.
>>>> The version of JENA I tested is 2.7.1
>>>
>>>There have been various improvements and fixes in this area which you'll
>>>find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT
>>>(from the Apache snapshot maven repository)
>>>
>>>    Andy
>>>
>>>> The code I rewrite the query is:
>>>> Query query = QueryFactory./create/(queryString);
>>>> AlgebraGenerator ag =
>>>> *new*AlgebraGenerator();
>>>> Op op = ag.compile(query);
>>>> Query query2 = OpAsQuery./asQuery/(op);
>>>> The original query is:
>>>> PREFIX dcterms: <http://purl.org/dc/terms/>
>>>> PREFIX dbpedia: <http://dbpedia.org/resource/>
>>>> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
>>>> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
>>>> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>>> ?holiday dcterms:subject ?country_cat
>>>> }GROUP by ?country_cat
>>>> }
>>>> {
>>>> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>>> WHERE {
>>>> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>>> ?holiday dcterms:subject ?country_cat
>>>> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
>>>> }GROUP by ?country_cat
>>>> }
>>>> }
>>>> The generated query is:
>>>> SELECT ?country_cat ?celebrate_Chinese_New_Year
>>>> WHERE
>>>> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>>> BIND(count(?holiday) AS ?num_of_holidays)
>>>> }
>>>> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>>> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day"
>>>>)
>>>> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
>>>> }
>>>> }
>>>> GROUP BY ?country_cat
>>>> The generated query has a syntax error: "Line 5, column 12: Aggregate
>>>> expression not legal at this point".
>>>> Attached is a hava program to demonstrate the problem,

Reply via email to