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 2017/04/26 09:04:04 UTC
[jira] [Commented] (JENA-1327) HAVING clause accepts projected
expression
[ https://issues.apache.org/jira/browse/JENA-1327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15984397#comment-15984397 ]
Andy Seaborne commented on JENA-1327:
-------------------------------------
It is correct.
{{HAVING}} is {{FILTER}} applied after aggregation sop {{?tw}} is in-scope. (The keyword nearly was {{FILTER}} not {{HAVING}} which is an SQL-hangover.)
{{SELECT}} does many things - not all of them happen at the point of projection.
Try the query at the [sparql.org query validator|http://www.sparql.org/validate/query].
{noformat}
PREFIX dbo: <http://purl.org/dc/elements/1.1/>
SELECT (COUNT(?work) AS ?tw) ?author
WHERE
{ ?work dbo:author ?author }
GROUP BY ?author
HAVING ( ?tw > 3 )
===> Algebra structure
(base <http://example/base/>
(prefix ((dbo: <http://purl.org/dc/elements/1.1/>))
(project (?tw ?author)
(filter (> ?tw 3) <----- Due to HAVING
(extend ((?tw ?.0))
(group (?author) ((?.0 (count ?work)))
(bgp (triple ?work dbo:author ?author))))))))
{noformat}
Note the position of {{(project)}} and the {{(count)}}, all from {{SELECT}}.
> HAVING clause accepts projected expression
> ------------------------------------------
>
> Key: JENA-1327
> URL: https://issues.apache.org/jira/browse/JENA-1327
> Project: Apache Jena
> Issue Type: Question
> Components: ARQ
> Affects Versions: Jena 3.1.1, Jena 3.2.0
> Reporter: Lorenz Bühmann
> Priority: Minor
>
> I'm wondering whether the SPARQL parser is correct with accepting the following query:
> {noformat}
> PREFIX dbo: <http://purl.org/dc/elements/1.1/>
> SELECT (COUNT(?work) AS ?tw) ?author
> WHERE
> { ?work dbo:author ?author }
> GROUP BY ?author
> HAVING ( ?tw > 3 )
> {noformat}
> According to the [specs|https://www.w3.org/TR/sparql11-query/#sparqlHavingClause], I would assume that this is not allowed and one has to use
> {noformat}
> PREFIX dbo: <http://purl.org/dc/elements/1.1/>
> SELECT (COUNT(?work) AS ?tw) ?author
> WHERE
> { ?work dbo:author ?author }
> GROUP BY ?author
> HAVING ( COUNT(?tw) > 3 )
> {noformat}
> But as always, I might misunderstand the specs.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)