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:14:45 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=14701035#comment-14701035 ] 

Andy Seaborne commented on JENA-1010:
-------------------------------------

See JENA-963. Fixed in Jena 3.0.0. The problem was in opAsQuery.  Output of the code above is:
{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
{code}
with 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
>
> 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)