Hi Rob, What is not SPARQL 1.1 about the query being run ie
select distinct ?T1 ?T2 count(*) from <http://dbpedia.org> where { ?s1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T1. ?s2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T2. ?s1 <http://dbpedia.org/property/spouse> ?s2. ?s2 <http://dbpedia.org/property/birthPlace> ?obj. FILTER(REGEX(?T1, "http://dbpedia.org/ontology/")). FILTER(REGEX(?T2, "http://dbpedia.org/ontology/")). } group by ?T1 ?T2 The only potential problem I see is the "count(*)" which maybe have to be changed to be "(count(*) as ?count)" as in the specs if this is not deemed to be SPARQL 1.1 ie select distinct ?T1 ?T2 (count(*) as ?count) from <http://dbpedia.org> where { ?s1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T1. ?s2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T2. ?s1 <http://dbpedia.org/property/spouse> ?s2. ?s2 <http://dbpedia.org/property/birthPlace> ?obj. FILTER(REGEX(?T1, "http://dbpedia.org/ontology/")). FILTER(REGEX(?T2, "http://dbpedia.org/ontology/")). } group by ?T1 ?T2 Which seems to work against other endpoints ... Would be nice if the Jena SPARQL validator at http://www.sparql.org/validator.html worked to check ? I note in the code Jena snippet below the call "QueryFactory.create(query, Syntax.syntaxSPARQL_11);" , which seems to be forcing the invocation of the Jena Parser, but if the "Syntax.syntaxSPARQL_11" param is removed then it should bypass the Jena parser and pass Query on to Virtuoso as is , as detailed at: http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtJenaProvider#Bypass%20Jena/ARQ%20parser Best Regards Hugh Williams Professional Services OpenLink Software, Inc. // http://www.openlinksw.com/ Weblog -- http://www.openlinksw.com/blogs/ LinkedIn -- http://www.linkedin.com/company/openlink-software/ Twitter -- http://twitter.com/OpenLink Google+ -- http://plus.google.com/100570109519069333827/ Facebook -- http://www.facebook.com/OpenLinkSoftware Universal Data Access, Integration, and Management Technology Providers On 12 May 2014, at 09:17, Rob Vesse <rve...@dotnetrdf.org> wrote: > Yes, though the Virtuoso specific syntax shown there is not legal SPARQL > > See Aggregates (http://www.w3.org/TR/sparql11-query/#aggregates) in the > SPARQL 1.1 specification which Jena fully supports > > Rob > > On 12/05/2014 05:49, "Md Mizanur Rahoman" <mi...@nii.ac.jp> wrote: > >> Dear Experts, >> >> My question is: >> >> Is there any Jena implementation that can execute Aggregate function like >> count, sum etc? Iterative counting of all elements could an option, >> however, I want to know about direct implement of below method. >> >> such as, the below method >> >> ------------------------------ >> ------------------------------------------------------------------------ >> public void queryExecutor(VirtGraph dataset) { >> >> String query = >> "select distinct ?T1 ?T2 count(*) "+ >> "from <http://dbpedia.org> "+ >> "where "+ >> "{ "+ >> "?s1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T1. "+ >> "?s2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T2. "+ >> "?s1 <http://dbpedia.org/property/spouse> ?s2. "+ >> "?s2 <http://dbpedia.org/property/birthPlace> ?obj. "+ >> "FILTER(REGEX(?T1, \"http://dbpedia.org/ontology/\")). "+ >> "FILTER(REGEX(?T2, \"http://dbpedia.org/ontology/\")). "+ >> "}"+ >> "group by ?T1 ?T2 "; >> >> >> System.out.println(query); >> >> Query sparql1 = QueryFactory.create(query, >> Syntax.syntaxSPARQL_11); >> try { >> VirtuosoQueryExecution vqe1 = >> VirtuosoQueryExecutionFactory.create(sparql1, dataset); >> ResultSet results1 = vqe1.execSelect(); >> >> } >> catch (Exception e) { >> System.out.println("Error in query execution: " + >> e.toString()); >> e.printStackTrace(); >> } >> >> } >> -------------------------------------------------------------------------- >> --------------------------------- >> >> >> - >> Regards >> Mizan >> NII, Japan >> >> >> >> ---------- Forwarded message ---------- >> From: Md Mizanur Rahoman <mi...@nii.ac.jp> >> Date: Wed, May 7, 2014 at 7:35 PM >> Subject: Group By Query in Jena Java >> To: users@jena.apache.org >> >> >> Dear Expert, >> >> I want to execute a group by query in Jena. I am using Jena V2.6.4. But it >> is giving exception >> -------------------------------------------------------------------------- >> --------------------------- >> >> Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: >> Encountered " "count" "count "" at line 1, column 26. >> >> -------------------------------------------------------------------------- >> ---------------------------- >> And here is my method, >> >> -------------------------------------------------------------------------- >> ---------------------------- >> public void queryExecutor(VirtGraph dataset) { >> >> String query = >> "select distinct ?T1 ?T2 count(*) "+ >> "from <http://dbpedia.org> "+ >> "where "+ >> "{ "+ >> "?s1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T1. "+ >> "?s2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?T2. "+ >> "?s1 <http://dbpedia.org/property/spouse> ?s2. "+ >> "?s2 <http://dbpedia.org/property/birthPlace> ?obj. "+ >> "FILTER(REGEX(?T1, \"http://dbpedia.org/ontology/\")). "+ >> "FILTER(REGEX(?T2, \"http://dbpedia.org/ontology/\")). "+ >> "}"+ >> "group by ?T1 ?T2 "; >> >> >> System.out.println(query); >> >> Query sparql1 = QueryFactory.create(query, >> Syntax.syntaxSPARQL_11); >> try { >> VirtuosoQueryExecution vqe1 = >> VirtuosoQueryExecutionFactory.create(sparql1, dataset); >> ResultSet results1 = vqe1.execSelect(); >> >> } >> catch (Exception e) { >> System.out.println("Error in query execution: " + >> e.toString()); >> e.printStackTrace(); >> } >> >> } >> -------------------------------------------------------------------------- >> --------------------------------- >> >> My question is: >> >> * Is there any Jena version that can execute Aggregate function like >> count, >> sum etc? >> >> - >> Regards >> Mizanur >> NII, Japan > > > >