[ 
https://issues.apache.org/jira/browse/JENA-495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13722849#comment-13722849
 ] 

Rob Vesse commented on JENA-495:
--------------------------------

This is not a regression AFAICT merely ARQ having been updated to correctly 
implement the specification for trailing VALUES clauses.

>From the spec Section 
>18.2.4(http://www.w3.org/TR/sparql11-query/#convertGroupAggSelectExpressions):

{quote}
In this step, we process clauses on the query level in the following order:

* Grouping
* Aggregates
* HAVING
* VALUES
* Select expressions
{quote}

Note that trailing VALUES applies after the aggregation step.

In the first two queries where the VALUES block is trailing it applies after 
the aggregates are calculated so it is expected that the ?sum and ?count 
variables would have values of 0, then the VALUES are joined in hence why you 
get two rows.  The prior behaviour in 2.7.1 may have been correct at the time 
but is incorrect wrt the final state of the specification.

In the third case an inline VALUES is joined in at the point where it appears 
(Section 18.2.2.6), by putting it inside the WHERE clause you ensure it is 
processed before the aggregation stage so you get the aggregate results that 
you expect.
                
> Regression in evaluation of aggregates with trailing VALUES
> -----------------------------------------------------------
>
>                 Key: JENA-495
>                 URL: https://issues.apache.org/jira/browse/JENA-495
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ, Jena
>    Affects Versions: Jena 2.10.1
>            Reporter: Mark Buquor
>
> {noformat}
> The following query returns {{x, 1},{x, 2}} with 2.7.1 and 2.10.1 as expected:
>  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>  SELECT *
>  WHERE {  }
>  VALUES ?x { 1 2 }
> The following query returns {{sum,3}} with 2.7.1. With 2.10.1, it returns no 
> results.
>  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>  SELECT (SUM(?x) AS ?sum)
>  WHERE {  }
>  VALUES ?x { 1 2 }
> The following query returns {{count,2}} with 2.7.1. With 2.10.1, it returns 
> {{count,0},{count,0}}.
>  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>  SELECT (COUNT(?x) AS ?count)
>  WHERE {  }
>  VALUES ?x { 1 2 }
> The queries work as expected with 2.10.1 if the VALUES is moved into the 
> WHERE. e.g.
>  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>  SELECT (COUNT(?x) AS ?count)
>  WHERE { VALUES ?x { 1 2 } }
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to