You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2015/08/18 12:37:46 UTC
[jira] [Resolved] (JENA-1010) Wrong parsing of aggregate functions
in HAVING clause
[ https://issues.apache.org/jira/browse/JENA-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andy Seaborne resolved JENA-1010.
---------------------------------
Resolution: Fixed
Fix Version/s: Jena 3.0.0
> Wrong parsing of aggregate functions in HAVING clause
> -----------------------------------------------------
>
> Key: JENA-1010
> URL: https://issues.apache.org/jira/browse/JENA-1010
> Project: Apache Jena
> Issue Type: Bug
> Components: Jena
> Affects Versions: Jena 2.13.0
> Reporter: Ruben Navarro Piris
> Assignee: Andy Seaborne
> Fix For: Jena 3.0.0
>
>
> Using an aggregate funtion (count) in the HAVING clause leads to some weird parsing. The following code reproduces the problem (output also provided)
> {code:java}
> public class Test {
> public static void main(String[] args) {
> AlgebraGenerator ag = new AlgebraGenerator();
> // this query counts the number of occurrences of a property
> // showing only properties with more than one occurrence
> String q =
> "SELECT (count(?o) AS ?c) ?prop "
> + "WHERE { GRAPH ?g { ?s ?prop ?o } } "
> + "GROUP BY ?prop HAVING ( count(?o) > 1 ) "
> + "ORDER BY DESC(?c) ?prop";
> Query query = QueryFactory.create(q);
> System.out.println(query);
> Op queryOp = ag.compile(query);
> System.out.println(queryOp);
>
> Query rewritten = OpAsQuery.asQuery(queryOp);
> System.out.println(rewritten);
> }
> }
> {code}
> {code}
> SELECT (COUNT(?o) AS ?c) ?prop
> WHERE
> { GRAPH ?g
> { ?s ?prop ?o}
> }
> GROUP BY ?prop
> HAVING ( COUNT(?o) > 1 )
> ORDER BY DESC(?c) ?prop
> (project (?c ?prop)
> (order ((desc ?c) ?prop)
> (filter (> ?.0 1)
> (extend ((?c ?.0))
> (group (?prop) ((?.0 (count ?o)))
> (graph ?g
> (bgp (triple ?s ?prop ?o))))))))
> SELECT ?c ?prop
> WHERE
> { { GRAPH ?g
> { ?s ?prop ?o}
> BIND(COUNT(?o) AS ?c)
> }
> FILTER ( ?.0 > 1 )
> }
> GROUP BY ?prop
> ORDER BY DESC(?c) ?prop
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)